Added faq 1.27 about GZIP output buffering problem.
[phpmyadmin/crack.git] / server_privileges.php3
blob99f00f5fbe4af45a9826dba4b518136a1346cea6
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
6 /**
7 * Does the common work
8 */
9 $js_to_run = 'server_privileges.js';
10 require('./server_common.inc.php3');
13 /**
14 * Checks if a dropdown box has been used for selecting a database / table
16 if (!empty($pred_dbname)) {
17 $dbname = $pred_dbname;
18 unset($pred_dbname);
20 if (!empty($pred_tablename)) {
21 $tablename = $pred_tablename;
22 unset($pred_tablename);
26 /**
27 * Checks if the user is allowed to do what he tries to...
29 if (!$is_superuser) {
30 include('./server_links.inc.php3');
31 echo '<h2>' . "\n"
32 . ' ' . $strPrivileges . "\n"
33 . '</h2>' . "\n"
34 . $strNoPrivileges . "\n";
35 include('./footer.inc.php3');
36 exit;
40 /**
41 * Extracts the privilege information of a priv table row
43 * @param array the row
44 * @param boolean add <dfn> tag with tooltips
46 * @global ressource the database connection
48 * @return array
50 function PMA_extractPrivInfo($row = '', $enableHTML = FALSE)
52 global $userlink;
54 $grants = array(
55 array('Select_priv', 'SELECT', $GLOBALS['strPrivDescSelect']),
56 array('Insert_priv', 'INSERT', $GLOBALS['strPrivDescInsert']),
57 array('Update_priv', 'UPDATE', $GLOBALS['strPrivDescUpdate']),
58 array('Delete_priv', 'DELETE', $GLOBALS['strPrivDescDelete']),
59 array('Create_priv', 'CREATE', $GLOBALS['strPrivDescCreateDb']),
60 array('Drop_priv', 'DROP', $GLOBALS['strPrivDescDropDb']),
61 array('Reload_priv', 'RELOAD', $GLOBALS['strPrivDescReload']),
62 array('Shutdown_priv', 'SHUTDOWN', $GLOBALS['strPrivDescShutdown']),
63 array('Process_priv', 'PROCESS', $GLOBALS['strPrivDescProcess' . ((!empty($row) && isset($row['Super_priv'])) || (empty($row) && isset($GLOBALS['Super_priv'])) ? '4' : '3')]),
64 array('File_priv', 'FILE', $GLOBALS['strPrivDescFile']),
65 array('References_priv', 'REFERENCES', $GLOBALS['strPrivDescReferences']),
66 array('Index_priv', 'INDEX', $GLOBALS['strPrivDescIndex']),
67 array('Alter_priv', 'ALTER', $GLOBALS['strPrivDescAlter']),
68 array('Show_db_priv', 'SHOW DATABASES', $GLOBALS['strPrivDescShowDb']),
69 array('Super_priv', 'SUPER', $GLOBALS['strPrivDescSuper']),
70 array('Create_tmp_table_priv', 'CREATE TEMPORARY TABLES', $GLOBALS['strPrivDescCreateTmpTable']),
71 array('Lock_tables_priv', 'LOCK TABLES', $GLOBALS['strPrivDescLockTables']),
72 array('Execute_priv', 'EXECUTE', $GLOBALS['strPrivDescExecute']),
73 array('Repl_slave_priv', 'REPLICATION SLAVE', $GLOBALS['strPrivDescReplSlave']),
74 array('Repl_client_priv', 'REPLICATION CLIENT', $GLOBALS['strPrivDescReplClient'])
76 if (!empty($row) && isset($row['Table_priv'])) {
77 $sql_query = 'SHOW COLUMNS FROM `tables_priv` LIKE "Table_priv";';
78 $res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
79 unset($sql_query);
80 $row1 = PMA_mysql_fetch_array($res, MYSQL_ASSOC);
81 mysql_free_result($res);
82 $av_grants = explode ('\',\'' , substr($row1['Type'], 5, strlen($row1['Type']) - 7));
83 unset($row1);
84 $users_grants = explode(',', $row['Table_priv']);
85 while (list(, $current_grant) = each($av_grants)) {
86 $row[$current_grant . '_priv'] = in_array($current_grant, $users_grants) ? 'Y' : 'N';
88 unset($current_grant);
89 unset($av_grants);
90 unset($users_grants);
92 $privs = array();
93 $allPrivileges = TRUE;
94 while (list(, $current_grant) = each($grants)) {
95 if ((!empty($row) && isset($row[$current_grant[0]])) || (empty($row) && isset($GLOBALS[$current_grant[0]]))) {
96 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'])))) {
97 if ($enableHTML) {
98 $privs[] = '<dfn title="' . $current_grant[2] . '">' . str_replace(' ', '&nbsp;', $current_grant[1]) . '</dfn>';
99 } else {
100 $privs[] = $current_grant[1];
102 } else if (!empty($GLOBALS[$current_grant[0]]) && is_array($GLOBALS[$current_grant[0]]) && empty($GLOBALS[$current_grant[0] . '_none'])) {
103 if ($enableHTML) {
104 $priv_string = '<dfn title="' . $current_grant[2] . '">' . str_replace(' ', '&nbsp;', $current_grant[1]) . '</dfn>';
105 } else {
106 $priv_string = $current_grant[1];
108 $privs[] = $priv_string . ' (`' . join('`, `', $GLOBALS[$current_grant[0]]) . '`)';
109 } else {
110 $allPrivileges = FALSE;
114 if (empty($privs)) {
115 if ($enableHTML) {
116 $privs[] = '<dfn title="' . $GLOBALS['strPrivDescUsage'] . '">USAGE</dfn>';
117 } else {
118 $privs[] = 'USAGE';
120 } else if ($allPrivileges && (!isset($GLOBALS['grant_count']) || count($privs) == $GLOBALS['grant_count'])) {
121 if ($enableHTML) {
122 $privs = array('<dfn title="' . $GLOBALS['strPrivDescAllPrivileges'] . '">ALL&nbsp;PRIVILEGES</dfn>');
123 } else {
124 $privs = array('ALL PRIVILEGES');
127 return $privs;
128 } // end of the 'PMA_extractPrivInfo()' function
131 * Displays the privileges form table
133 * @param string the database
134 * @param string the table
135 * @param boolean wheather to display the submit button or not
136 * @param int the indenting level of the code
138 * @global array the phpMyAdmin configuration
139 * @global ressource the database connection
141 * @return void
143 function PMA_displayPrivTable($db = '*', $table = '*', $submit = TRUE, $indent = 0)
145 global $cfg, $userlink;
147 if ($db == '*') {
148 $table = '*';
150 $spaces = '';
151 for ($i = 0; $i < $indent; $i++) {
152 $spaces .= ' ';
154 if (isset($GLOBALS['username'])) {
155 $username = $GLOBALS['username'];
156 if (empty($GLOBALS['hostname'])) {
157 $hostname = '%';
158 } else {
159 $hostname = $GLOBALS['hostname'];
161 if ($db == '*') {
162 $sql_query = 'SELECT * FROM `user` WHERE `User` = "' . $username . '" AND `Host` = "' . $hostname . '";';
163 } else if ($table == '*') {
164 $sql_query = 'SELECT * FROM `db` WHERE `User` = "' . $username . '" AND `Host` = "' . $hostname . '" AND `Db` = "' . $db . '";';
165 } else {
166 $sql_query = 'SELECT `Table_priv` FROM `tables_priv` WHERE `User` = "' . $username . '" AND `Host` = "' . $hostname . '" AND `Db` = "' . $db . '" AND `Table_name` = "' . $table . '";';
168 $res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
169 if ($res) {
170 $row = PMA_mysql_fetch_array($res, MYSQL_ASSOC);
172 @mysql_free_result($res);
174 if (empty($row)) {
175 if ($table == '*') {
176 if ($db == '*') {
177 $sql_query = 'SHOW COLUMNS FROM `mysql`.`user`;';
178 } else if ($table == '*') {
179 $sql_query = 'SHOW COLUMNS FROM `mysql`.`db`;';
181 $res = PMA_mysql_query($sql_query, $userlink)
182 or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
183 while ($row1 = PMA_mysql_fetch_row($res)) {
184 if (substr($row1[0], 0, 4) == 'max_') {
185 $row[$row1[0]] = 0;
186 } else {
187 $row[$row1[0]] = 'N';
190 mysql_free_result($res);
191 } else {
192 $row = array('Table_priv' => '');
195 if (isset($row['Table_priv'])) {
196 $sql_query = 'SHOW COLUMNS FROM `tables_priv` LIKE "Table_priv";';
197 $res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
198 unset($sql_query);
199 $row1 = PMA_mysql_fetch_array($res, MYSQL_ASSOC);
200 mysql_free_result($res);
201 $av_grants = explode ('\',\'' , substr($row1['Type'], 5, strlen($row1['Type']) - 7));
202 unset($row1);
203 $users_grants = explode(',', $row['Table_priv']);
204 while (list(, $current_grant) = each($av_grants)) {
205 $row[$current_grant . '_priv'] = in_array($current_grant, $users_grants) ? 'Y' : 'N';
207 unset($row['Table_priv']);
208 unset($current_grant);
209 unset($av_grants);
210 unset($users_grants);
211 if ($res = PMA_mysql_query('SHOW COLUMNS FROM `' . $db . '`.`' . $table . '`;', $userlink)) {
212 $columns = array();
213 while ($row1 = PMA_mysql_fetch_row($res)) {
214 $columns[$row1[0]] = array(
215 'Select' => FALSE,
216 'Insert' => FALSE,
217 'Update' => FALSE,
218 'References' => FALSE
221 mysql_free_result($res);
222 unset($res);
223 unset($row1);
226 if (!empty($columns)) {
227 $sql_query = 'SELECT `Column_name`, `Column_priv` FROM `columns_priv` WHERE `User` = "' . $username . '" AND `Host` = "' . $hostname . '" AND `Db` = "' . $db . '" AND `Table_name` = "' . $table . '";';
228 $res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
229 while ($row1 = PMA_mysql_fetch_row($res)) {
230 $row1[1] = explode(',', $row1[1]);
231 while (list(, $current) = each($row1[1])) {
232 $columns[$row1[0]][$current] = TRUE;
235 mysql_free_result($res);
236 unset($res);
237 unset($row1);
238 unset($current);
239 echo $spaces . '<input type="hidden" name="grant_count" value="' . count($row) . '" />' . "\n"
240 . $spaces . '<input type="hidden" name="column_count" value="' . count($columns) . '" />' . "\n"
241 . $spaces . '<table border="0">' . "\n"
242 . $spaces . ' <tr>' . "\n"
243 . $spaces . ' <th colspan="6">&nbsp;' . $GLOBALS['strTblPrivileges'] . '&nbsp;</th>' . "\n"
244 . $spaces . ' </tr>' . "\n"
245 . $spaces . ' <tr>' . "\n"
246 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '" colspan="6"><small><i>' . $GLOBALS['strEnglishPrivileges'] . '</i></small></td>' . "\n"
247 . $spaces . ' </tr>' . "\n"
248 . $spaces . ' <tr>' . "\n"
249 . $spaces . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">&nbsp;<tt><dfn title="' . $GLOBALS['strPrivDescSelect'] . '">SELECT</dfn></tt>&nbsp;</td>' . "\n"
250 . $spaces . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">&nbsp;<tt><dfn title="' . $GLOBALS['strPrivDescInsert'] . '">INSERT</dfn></tt>&nbsp;</td>' . "\n"
251 . $spaces . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">&nbsp;<tt><dfn title="' . $GLOBALS['strPrivDescUpdate'] . '">UPDATE</dfn></tt>&nbsp;</td>' . "\n"
252 . $spaces . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">&nbsp;<tt><dfn title="' . $GLOBALS['strPrivDescReferences'] . '">REFERENCES</dfn></tt>&nbsp;</td>' . "\n";
253 list($current_grant, $current_grant_value) = each($row);
254 while (in_array(substr($current_grant, 0, (strlen($current_grant) - 5)), array('Select', 'Insert', 'Update', 'References'))) {
255 list($current_grant, $current_grant_value) = each($row);
257 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"
258 . $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"
259 . $spaces . ' </tr>' . "\n"
260 . $spaces . ' <tr>' . "\n";
261 $rowspan = count($row) - 5;
262 echo $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '" rowspan="' . $rowspan . '" valign="top">' . "\n"
263 . $spaces . ' <select name="Select_priv[]" multiple="multiple">' . "\n";
264 while (list($current_column, $current_column_privileges) = each($columns)) {
265 echo $spaces . ' <option value="' . htmlspecialchars($current_column) . '"';
266 if ($row['Select_priv'] == 'Y' || $current_column_privileges['Select']) {
267 echo ' selected="selected"';
269 echo '>' . htmlspecialchars($current_column) . '</option>' . "\n";
271 echo $spaces . ' </select><br />' . "\n"
272 . $spaces . ' </td>' . "\n"
273 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '" rowspan="' . $rowspan . '" valign="top">' . "\n"
274 . $spaces . ' <select name="Insert_priv[]" multiple="multiple">' . "\n";
275 reset($columns);
276 while (list($current_column, $current_column_privileges) = each($columns)) {
277 echo $spaces . ' <option value="' . htmlspecialchars($current_column) . '"';
278 if ($row['Insert_priv'] == 'Y' || $current_column_privileges['Insert']) {
279 echo ' selected="selected"';
281 echo '>' . htmlspecialchars($current_column) . '</option>' . "\n";
283 echo $spaces . ' </select>' . "\n"
284 . $spaces . ' </td>' . "\n"
285 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '" rowspan="' . $rowspan . '" valign="top">' . "\n"
286 . $spaces . ' <select name="Update_priv[]" multiple="multiple">' . "\n";
287 reset($columns);
288 while (list($current_column, $current_column_privileges) = each($columns)) {
289 echo $spaces . ' <option value="' . htmlspecialchars($current_column) . '"';
290 if ($row['Update_priv'] == 'Y' || $current_column_privileges['Update']) {
291 echo ' selected="selected"';
293 echo '>' . htmlspecialchars($current_column) . '</option>' . "\n";
295 echo $spaces . ' </select>' . "\n"
296 . $spaces . ' </td>' . "\n"
297 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '" rowspan="' . $rowspan . '" valign="top">' . "\n"
298 . $spaces . ' <select name="References_priv[]" multiple="multiple">' . "\n";
299 reset($columns);
300 while (list($current_column, $current_column_privileges) = each($columns)) {
301 echo $spaces . ' <option value="' . htmlspecialchars($current_column) . '"';
302 if ($row['References_priv'] == 'Y' || $current_column_privileges['References']) {
303 echo ' selected="selected"';
305 echo '>' . htmlspecialchars($current_column) . '</option>' . "\n";
307 echo $spaces . ' </select>' . "\n"
308 . $spaces . ' </td>' . "\n";
309 unset($rowspan);
310 list($current_grant, $current_grant_value) = each($row);
311 while (in_array(substr($current_grant, 0, (strlen($current_grant) - 5)), array('Select', 'Insert', 'Update', 'References'))) {
312 list($current_grant, $current_grant_value) = each($row);
314 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"
315 . $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"
316 . $spaces . ' </tr>' . "\n";
317 while (list($current_grant, $current_grant_value) = each($row)) {
318 if (in_array(substr($current_grant, 0, (strlen($current_grant) - 5)), array('Select', 'Insert', 'Update', 'References'))) {
319 continue;
321 echo $spaces . ' <tr>' . "\n"
322 . $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"
323 . $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"
324 . $spaces . ' </tr>' . "\n";
326 } else {
327 $privTable[0] = array(
328 array('Select', 'SELECT', $GLOBALS['strPrivDescSelect']),
329 array('Insert', 'INSERT', $GLOBALS['strPrivDescInsert']),
330 array('Update', 'UPDATE', $GLOBALS['strPrivDescUpdate']),
331 array('Delete', 'DELETE', $GLOBALS['strPrivDescDelete'])
333 if ($db == '*') {
334 $privTable[0][] = array('File', 'FILE', $GLOBALS['strPrivDescFile']);
336 $privTable[1] = array(
337 array('Create', 'CREATE', ($table == '*' ? $GLOBALS['strPrivDescCreateDb'] : $GLOBALS['strPrivDescCreateTbl'])),
338 array('Alter', 'ALTER', $GLOBALS['strPrivDescAlter']),
339 array('Index', 'INDEX', $GLOBALS['strPrivDescIndex']),
340 array('Drop', 'DROP', ($table == '*' ? $GLOBALS['strPrivDescDropDb'] : $GLOBALS['strPrivDescDropTbl']))
342 if (isset($row['Create_tmp_table_priv'])) {
343 $privTable[1][] = array('Create_tmp_table', 'CREATE&nbsp;TEMPORARAY&nbsp;TABLES', $GLOBALS['strPrivDescCreateTmpTable']);
345 $privTable[2] = array();
346 if (isset($row['Grant_priv'])) {
347 $privTable[2][] = array('Grant', 'GRANT', $GLOBALS['strPrivDescGrant']);
349 if ($db == '*') {
350 if (isset($row['Super_priv'])) {
351 $privTable[2][] = array('Super', 'SUPER', $GLOBALS['strPrivDescSuper']);
352 $privTable[2][] = array('Process', 'PROCESS', $GLOBALS['strPrivDescProcess4']);
353 } else {
354 $privTable[2][] = array('Process', 'PROCESS', $GLOBALS['strPrivDescProcess3']);
356 $privTable[2][] = array('Reload', 'RELOAD', $GLOBALS['strPrivDescReload']);
357 $privTable[2][] = array('Shutdown', 'SHUTDOWN', $GLOBALS['strPrivDescShutdown']);
358 if (isset($row['Show_db_priv'])) {
359 $privTable[2][] = array('Show_db', 'SHOW&nbsp;DATABASES', $GLOBALS['strPrivDescShowDb']);
361 if (isset($row['Lock_tables_priv'])) {
362 $privTable[2][] = array('Lock_tables', 'LOCK&nbsp;TABLES', $GLOBALS['strPrivDescLockTables']);
365 $privTable[2][] = array('References', 'REFERENCES', $GLOBALS['strPrivDescReferences']);
366 if ($db == '*') {
367 if (isset($row['Execute_priv'])) {
368 $privTable[2][] = array('Execute', 'EXECUTE', $GLOBALS['strPrivDescExecute']);
370 if (isset($row['Repl_client_priv'])) {
371 $privTable[2][] = array('Repl_client', 'REPLICATION&nbsp;CLIENT', $GLOBALS['strPrivDescReplClient']);
373 if (isset($row['Repl_slave_priv'])) {
374 $privTable[2][] = array('Repl_slave', 'REPLICATION&nbsp;SLAVE', $GLOBALS['strPrivDescReplSlave']);
377 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"
378 . $spaces . '<table border="0">' . "\n"
379 . $spaces . ' <tr>' . "\n"
380 . $spaces . ' <th colspan="6">&nbsp;' . ($db == '*' ? $GLOBALS['strGlobalPrivileges'] : ($table == '*' ? $GLOBALS['strDbPrivileges'] : $GLOBALS['strTblPrivileges'])) . '&nbsp;</th>' . "\n"
381 . $spaces . ' </tr>' . "\n"
382 . $spaces . ' <tr>' . "\n"
383 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '" colspan="6"><small><i>' . $GLOBALS['strEnglishPrivileges'] . '</i></small></td>' . "\n"
384 . $spaces . ' </tr>' . "\n"
385 . $spaces . ' <tr>' . "\n"
386 . $spaces . ' <td bgcolor="' . $cfg['BgcolorOne'] . '" colspan="2">&nbsp;<b><i>' . $GLOBALS['strData'] . '</i></b>&nbsp;</td>' . "\n"
387 . $spaces . ' <td bgcolor="' . $cfg['BgcolorOne'] . '" colspan="2">&nbsp;<b><i>' . $GLOBALS['strStructure'] . '</i></b>&nbsp;</td>' . "\n"
388 . $spaces . ' <td bgcolor="' . $cfg['BgcolorOne'] . '" colspan="2">&nbsp;<b><i>' . $GLOBALS['strAdministration'] . '</i></b>&nbsp;</td>' . "\n"
389 . $spaces . ' </tr>' . "\n";
390 $limitTable = FALSE;
391 for ($i = 0; isset($privTable[0][$i]) || isset($privTable[1][$i]) || isset($privTable[2][$i]); $i++) {
392 echo $spaces . ' <tr>' . "\n";
393 for ($j = 0; $j < 3; $j++) {
394 if (isset($privTable[$j][$i])) {
395 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"
396 . $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";
397 } else if ($db == '*' && !isset($privTable[0][$i]) && !isset($privTable[1][$i])
398 && isset($row['max_questions']) && isset($row['max_updates']) && isset($row['max_connections'])
399 && !$limitTable) {
400 echo $spaces . ' <td colspan="4" rowspan="' . (count($privTable[2]) - $i) . '">' . "\n"
401 . $spaces . ' <table border="0">' . "\n"
402 . $spaces . ' <tr>' . "\n"
403 . $spaces . ' <th colspan="2">&nbsp;' . $GLOBALS['strResourceLimits'] . '&nbsp;</th>' . "\n"
404 . $spaces . ' </tr>' . "\n"
405 . $spaces . ' <tr>' . "\n"
406 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '" colspan="2"><small><i>' . $GLOBALS['strZeroRemovesTheLimit'] . '</i></small></td>' . "\n"
407 . $spaces . ' </tr>' . "\n"
408 . $spaces . ' <tr>' . "\n"
409 . $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"
410 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><input type="text" name="max_questions" id="text_max_questions" value="' . $row['max_questions'] . '" size="11" maxlength="11" title="' . $GLOBALS['strPrivDescMaxQuestions'] . '" /></td>' . "\n"
411 . $spaces . ' </tr>' . "\n"
412 . $spaces . ' <tr>' . "\n"
413 . $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"
414 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><input type="text" name="max_updates" id="text_max_updates" value="' . $row['max_updates'] . '" size="11" maxlength="11" title="' . $GLOBALS['strPrivDescMaxUpdates'] . '" /></td>' . "\n"
415 . $spaces . ' </tr>' . "\n"
416 . $spaces . ' <tr>' . "\n"
417 . $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"
418 . $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><input type="text" name="max_connections" id="text_max_connections" value="' . $row['max_connections'] . '" size="11" maxlength="11" title="' . $GLOBALS['strPrivDescMaxConnections'] . '" /></td>' . "\n"
419 . $spaces . ' </tr>' . "\n"
420 . $spaces . ' </table>' . "\n"
421 . $spaces . ' </td>' . "\n";
422 $limitTable = TRUE;
423 } else if (!$limitTable) {
424 echo $spaces . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '" colspan="2">&nbsp;</td>' . "\n";
428 echo $spaces . ' </tr>' . "\n";
430 if ($submit) {
431 echo $spaces . ' <tr>' . "\n"
432 . $spaces . ' <td colspan="6" align="center">' . "\n"
433 . $spaces . ' <input type="submit" name="update_privs" value="' . $GLOBALS['strGo'] . '" />' . "\n"
434 . $spaces . ' </td>' . "\n"
435 . $spaces . ' </tr>' . "\n";
437 echo $spaces . '</table>' . "\n";
438 } // end of the 'PMA_displayPrivTable()' function
442 * Adds a user
444 if (!empty($adduser_submit)) {
445 unset($sql_query);
446 if ($pred_username == 'any') {
447 $username = '';
449 switch ($pred_hostname) {
450 case 'any':
451 $hostname = '%';
452 break;
453 case 'localhost':
454 $hostname = 'localhost';
455 break;
456 case 'thishost':
457 $res = PMA_mysql_query('SELECT USER();', $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), 'SELECT USER();');
458 $row = PMA_mysql_fetch_row($res);
459 mysql_free_result($res);
460 unset($res);
461 $hostname = substr($row[0], (strrpos($row[0], '@') + 1));
462 unset($row);
463 break;
465 $local_query = 'SELECT "foo" FROM `user` WHERE `User` = "' . $username . '" AND `Host` = "' . $hostname . '";';
466 $res = PMA_mysql_query($local_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $local_query);
467 unset($local_query);
468 if (mysql_affected_rows($userlink) == 1) {
469 $message = sprintf($strUserAlreadyExists, '<i>\'' . $username . '\'@\'' . $hostname . '\'</i>');
470 $adduser = 1;
471 } else {
472 if (PMA_MYSQL_INT_VERSION >= 32211) {
473 $real_sql_query = 'GRANT ' . join(', ', PMA_extractPrivInfo()) . ' ON *.* TO "' . $username . '"@"' . $hostname . '"';
474 if ($pred_password != 'none') {
475 $pma_pw_hidden = '';
476 for ($i = 0; $i < strlen($pma_pw); $i++) {
477 $pma_pw_hidden .= '*';
479 $sql_query = $real_sql_query . ' IDENTIFIED BY "' . $pma_pw_hidden . '"';
480 $real_sql_query .= ' IDENTIFIED BY "' . $pma_pw . '"';
481 } else {
482 $sql_query = $real_sql_query;
484 if ((isset($Grant_priv) && $Grant_priv == 'Y') || isset($max_questions) || isset($max_connections) || isset($max_updates)) {
485 $real_sql_query .= 'WITH';
486 $sql_query .= 'WITH';
487 if (isset($Grant_priv) && $Grant_priv == 'Y') {
488 $real_sql_query .= ' GRANT OPTION';
489 $sql_query .= ' GRANT OPTION';
491 if (isset($max_questions)) {
492 $real_sql_query .= ' MAX_QUERIES_PER_HOUR ' . (int)$max_questions;
493 $sql_query .= ' MAX_QUERIES_PER_HOUR ' . (int)$max_questions;
495 if (isset($max_connections)) {
496 $real_sql_query .= ' MAX_CONNECTIONS_PER_HOUR ' . (int)$max_connections;
497 $sql_query .= ' MAX_CONNECTIONS_PER_HOUR ' . (int)$max_connections;
499 if (isset($max_updates)) {
500 $real_sql_query .= ' MAX_UPDATES_PER_HOUR ' . (int)$max_updates;
501 $sql_query .= ' MAX_UPDATES_PER_HOUR ' . (int)$max_updates;
504 $real_sql_query .= ';';
505 $sql_query .= ';';
506 PMA_mysql_query($real_sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink));
507 unset($real_sql_query);
508 $message = $strAddUserMessage;
509 } else {
510 $privileges = PMA_extractPrivInfo();
511 $real_sql_query = 'INSERT INTO `user` SET `Host` = "' . $hostname . '", `User` = "' . $username . '"';
512 if ($pred_password != 'none') {
513 $pma_pw_hidden = '';
514 for ($i = 0; $i < strlen($pma_pw); $i++) {
515 $pma_pw_hidden .= '*';
517 $sql_query = $real_sql_query . ', `Password` = PASSWORD("' . $pma_pw_hidden . '")';
518 $real_sql_query .= ', `Password` = PASSWORD("' . $pma_pw . '")';
519 } else {
520 $sql_query = $real_sql_query;
522 while (list(, $priv) = each($privileges)) {
523 $real_sql_query .= ', `' . substr($priv, 0, 1) . strtolower(substr($priv, 1)) . '_priv` = "Y"';
524 $sql_query .= ', `' . substr($priv, 0, 1) . strtolower(substr($priv, 1)) . '_priv` = "Y"';
526 PMA_mysql_query($real_sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink));
527 unset($real_sql_query);
528 $message = $strAddUserMessage . '<br />' . "\n" . $strRememberReload;
530 mysql_free_result($res);
531 unset($res);
537 * Updates privileges
539 if (!empty($update_privs)) {
540 if (empty($hostname)) {
541 $hostname = '%';
543 if (PMA_MYSQL_INT_VERSION >= 32211) {
544 $db_and_table = empty($dbname) ? '*.*' : PMA_backquote($dbname) . '.' . (empty($tablename) ? '*' : PMA_backquote($tablename));
545 $sql_query0 = 'REVOKE ALL PRIVILEGES ON ' . $db_and_table . ' FROM "' . $username . '"@"' . $hostname . '";';
546 $sql_query1 = 'REVOKE GRANT OPTION ON ' . $db_and_table . ' FROM "' . $username . '"@"' . $hostname . '";';
547 $sql_query2 = 'GRANT ' . join(', ', PMA_extractPrivInfo()) . ' ON ' . $db_and_table . ' TO "' . $username . '"@"' . $hostname . '"';
548 if ((isset($Grant_priv) && $Grant_priv == 'Y') || (empty($dbname) && (isset($max_questions) || isset($max_connections) || isset($max_updates)))) {
549 $sql_query2 .= 'WITH';
550 if (isset($Grant_priv) && $Grant_priv == 'Y') {
551 $sql_query2 .= ' GRANT OPTION';
553 if (isset($max_questions)) {
554 $sql_query2 .= ' MAX_QUERIES_PER_HOUR ' . (int)$max_questions;
556 if (isset($max_connections)) {
557 $sql_query2 .= ' MAX_CONNECTIONS_PER_HOUR ' . (int)$max_connections;
559 if (isset($max_updates)) {
560 $sql_query2 .= ' MAX_UPDATES_PER_HOUR ' . (int)$max_updates;
563 $sql_query2 .= ';';
564 PMA_mysql_query($sql_query0, $userlink); // this query may fail, but this does not matter :o)
565 PMA_mysql_query($sql_query1, $userlink); // this one may fail, too...
566 PMA_mysql_query($sql_query2, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query2);
567 $sql_query = $sql_query0 . ' ' . $sql_query1 . ' ' . $sql_query2;
568 $message = sprintf($strUpdatePrivMessage, '\'' . $username . '\'@\'' . $hostname . '\'');
569 } else {
570 $sql_query = 'SHOW COLUMNS FROM `user`;';
571 $res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink));
572 $grants = array();
573 while ($row = PMA_mysql_fetch_row($res)) {
574 if (substr($row[0], -5) == '_priv') {
575 $grants[] = PMA_backquote($row[0]) . ' = "' . (empty($$row[0]) ? 'N' : 'Y') . '"';
578 mysql_free_result($res);
579 unset($res);
580 unset($row);
581 $sql_query = 'UPDATE `user` SET ' . join(', ', $grants) . ' WHERE `User` = "' . $username . '" AND `Host` = "' . $hostname . '";';
582 PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink));
583 $message = sprintf($strUpdatePrivMessage, '\'' . $username . '\'@\'' . $hostname . '\'') . '<br />' . "\n" . $strRememberReload;
589 * Revokes Privileges
591 if (!empty($revokeall)) {
592 if (empty($hostname)) {
593 $hostname = '%';
595 if (PMA_MYSQL_INT_VERSION >= 32211) {
596 $db_and_table = PMA_backquote($dbname) . '.' . (empty($tablename) ? '*' : PMA_backquote($tablename));
597 $sql_query0 = 'REVOKE ALL PRIVILEGES ON ' . $db_and_table . ' FROM "' . $username . '"@"' . $hostname . '";';
598 $sql_query1 = 'REVOKE GRANT OPTION ON ' . $db_and_table . ' FROM "' . $username . '"@"' . $hostname . '";';
599 PMA_mysql_query($sql_query0, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query0);
600 PMA_mysql_query($sql_query1, $userlink); // this one may fail, too...
601 $sql_query = $sql_query0 . ' ' . $sql_query1;
602 $message = sprintf($strRevokeMessage, '\'' . $username . '\'@\'' . $hostname . '\'');
604 if (empty($tablename)) {
605 unset($dbname);
606 } else {
607 unset($tablename);
613 * Updates the password
615 if (!empty($change_pw)) {
616 if (empty($hostname)) {
617 $hostname = '%';
619 if ($nopass == 1) {
620 $sql_query = 'SET PASSWORD FOR "' . $username . '"@"' . $hostname . '" = ""';
621 PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink));
622 $message = sprintf($strPasswordChanged, '\'' . $username . '\'@\'' . $hostname . '\'');
623 } else if (empty($pma_pw) || empty($pma_pw2)) {
624 $message = $strPasswordEmpty;
625 } else if ($pma_pw != $pma_pw2) {
626 $message = $strPasswordNotSame;
627 } else {
628 $hidden_pw = '';
629 for ($i = 0; $i < strlen($pma_pw); $i++) {
630 $hidden_pw .= '*';
632 $local_query = 'SET PASSWORD FOR "' . $username . '"@"' . $hostname . '" = PASSWORD("' . $pma_pw . '")';
633 $sql_query = 'SET PASSWORD FOR "' . $username . '"@"' . $hostname . '" = PASSWORD("' . $hidden_pw . '")';
634 PMA_mysql_query($local_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink));
635 $message = sprintf($strPasswordChanged, '\'' . $username . '\'@\'' . $hostname . '\'');
641 * Deletes users
643 if (!empty($delete)) {
644 $queries = array();
645 for ($i = 0; isset($selected_usr[$i]); $i++) {
646 list($this_user, $this_host) = explode('@', $selected_usr[$i]);
647 $queries[] = '# ' . sprintf($strDeleting, '\'' . $this_user . '\'@\'' . $this_host . '\'') . ' ...';
648 if ($mode == 2) {
649 // The SHOW GRANTS query may fail if the user has not been loaded
650 // into memory
651 $res = PMA_mysql_query('SHOW GRANTS FOR "' . $this_user . '"@"' . $this_host . '";', $userlink);
652 if ($res) {
653 $queries[] = 'REVOKE ALL PRIVILEGES ON *.* FROM "' . $this_user . '"@"' . $this_host . '";';
654 while ($row = PMA_mysql_fetch_row($res)) {
655 $this_table = substr($row[0], (strpos($row[0], 'ON') + 3), -(9 + strlen($this_user . $this_host)));
656 if ($this_table != '*.*') {
657 $queries[] = 'REVOKE ALL PRIVILEGES ON ' . $this_table . ' FROM "' . $this_user . '"@"' . $this_host . '";';
659 unset($this_table);
661 mysql_free_result($res);
663 unset($res);
665 $queries[] = 'DELETE FROM `user` WHERE `User` = "' . $this_user . '" AND `Host` = "' . $this_host . '";';
666 if ($mode != 2) {
667 // If we REVOKE the table grants, we should not need to modify the
668 // `db`, `tables_priv` and `columns_priv` tables manually...
669 $queries[] = 'DELETE FROM `db` WHERE `User` = "' . $this_user . '" AND `Host` = "' . $this_host . '";';
670 $queries[] = 'DELETE FROM `tables_priv` WHERE `User` = "' . $this_user . '" AND `Host` = "' . $this_host . '";';
671 $queries[] = 'DELETE FROM `columns_priv` WHERE `User` = "' . $this_user . '" AND `Host` = "' . $this_host . '";';
673 if (!empty($drop_users_db)) {
674 $queries[] = 'DROP DATABASE IF EXISTS ' . PMA_backquote($this_user) . ';';
677 if (empty($queries)) {
678 $message = $strError . ': ' . $strDeleteNoUsersSelected;
679 } else {
680 if ($mode == 3) {
681 $queries[] = '# ' . $strReloadingThePrivileges . ' ...';
682 $queries[] = 'FLUSH PRIVILEGES;';
684 while (list(, $sql_query) = each($queries)) {
685 if (substr($sql_query, 0, 1) != '#') {
686 PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink));
689 $sql_query = join("\n", $queries);
690 $message = $strUsersDeleted;
692 unset($queries);
697 * Reloads the privilege tables into memory
699 if (!empty($flush_privileges)) {
700 $sql_query = 'FLUSH PRIVILEGES';
701 if (@PMA_mysql_query($sql_query, $userlink)) {
702 $message = $strPrivilegesReloaded;
703 } else {
704 PMA_mysqlDie(PMA_mysql_error($userlink));
710 * Displays the links
712 require('./server_links.inc.php3');
716 * Displays the page
718 if (empty($adduser)) {
719 if (!isset($username)) {
720 // No username is given --> display the overview
721 echo '<h2>' . "\n"
722 . ' ' . $strUserOverview . "\n"
723 . '</h2>' . "\n";
724 $oldPrivTables = FALSE;
725 if (PMA_MYSQL_INT_VERSION >= 40002) {
726 $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);
727 if (!$res) {
728 // the query failed! This may have two reasons:
729 // - the user has not enough privileges
730 // - the privilege tables use a structure of an earlier version.
731 $oldPrivTables = TRUE;
734 if (empty($res) || (PMA_MYSQL_INT_VERSION >= 32211 && PMA_MYSQL_INT_VERSION < 40002)) {
735 $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);
736 if (!$res) {
737 // the query failed! This may have two reasons:
738 // - the user has not enough privileges
739 // - the privilege tables use a structure of an earlier version.
740 $oldPrivTables = TRUE;
743 if (empty($res) || PMA_MYSQL_INT_VERSION < 32211) {
744 $res = PMA_mysql_query('SELECT * FROM `user` ORDER BY `User` ASC, `Host` ASC;', $userlink);
746 if (!$res) {
747 echo '<i>' . $strNoPrivileges . '</i>' . "\n";
748 @mysql_free_result($res);
749 unset($res);
750 } else {
751 if ($oldPrivTables) {
752 // rabus: This message is hardcoded because I will replace it by
753 // a automatic repair feature soon.
754 echo '<div class="warning">' . "\n"
755 . ' Warning: Your privilege table structure seem to be older than this MySQL version!<br />' . "\n"
756 . ' Please run the script <tt>mysql_fix_privilege_tables</tt> that should be included in your MySQL server distribution to solve this problem!' . "\n"
757 . '</div><br />' . "\n";
759 echo '<form name="usersForm" action="server_privileges.php3" method="post" />' . "\n"
760 . PMA_generate_common_hidden_inputs('', '', 1)
761 . ' <table border="0">' . "\n"
762 . ' <tr>' . "\n"
763 . ' <th></th>' . "\n"
764 . ' <th>&nbsp;' . $strUser . '&nbsp;</th>' . "\n"
765 . ' <th>&nbsp;' . $strHost . '&nbsp;</th>' . "\n"
766 . ' <th>&nbsp;' . $strPassword . '&nbsp;</th>' . "\n"
767 . ' <th>&nbsp;' . $strGlobalPrivileges . '&nbsp;</th>' . "\n"
768 . ' <th>&nbsp;' . $strGrantOption . '&nbsp;</th>' . "\n"
769 . ' <th>&nbsp;' . $strAction . '&nbsp;</th>' . "\n";
770 echo ' </tr>' . "\n";
771 $useBgcolorOne = TRUE;
772 for ($i = 0; $row = PMA_mysql_fetch_array($res, MYSQL_ASSOC); $i++) {
773 echo ' <tr>' . "\n"
774 . ' <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"
775 . ' <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"
776 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . htmlspecialchars($row['Host']) . '</td>' . "\n";
777 $privs = PMA_extractPrivInfo($row, TRUE);
778 echo ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . ($row['Password'] == 'Y' ? $strYes : '<span style="color: #FF0000">' . $strNo . '</span>') . '</td>' . "\n"
779 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><tt>' . "\n"
780 . ' ' . join(',' . "\n" . ' ', $privs) . "\n"
781 . ' </tt></td>' . "\n"
782 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . ($row['Grant_priv'] == 'Y' ? $strYes : $strNo) . '</td>' . "\n"
783 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><a href="server_privileges.php3?' . $url_query . '&amp;username=' . urlencode($row['User']) . ($row['Host'] == '%' ? '' : '&amp;hostname=' . urlencode($row['Host'])) . '">' . $strEdit . '</a></td>' . "\n"
784 . ' </tr>' . "\n";
785 $useBgcolorOne = !$useBgcolorOne;
787 @mysql_free_result($res);
788 unset($res);
789 unset ($row);
790 echo ' <tr>' . "\n"
791 . ' <td></td>' . "\n"
792 . ' <td colspan="5">' . "\n"
793 . ' &nbsp;<i>' . $strEnglishPrivileges . '</i>&nbsp;' . "\n"
794 . ' </td>' . "\n"
795 . ' </tr>' . "\n"
796 . ' <tr>' . "\n"
797 . ' <td colspan="6" valign="bottom">' . "\n"
798 . ' <img src="./images/arrow_' . $text_dir . '.gif" border="0" width="38" height="22" alt="' . $strWithChecked . '" />' . "\n"
799 . ' <a href="./server_privileges.php3?' . $url_query . '&amp;checkall=1" onclick="setCheckboxes(\'usersForm\', \'selected_usr\', true); return false;">' . $strCheckAll . '</a>' . "\n"
800 . ' &nbsp;/&nbsp;' . "\n"
801 . ' <a href="server_privileges.php3' . $url_query . '" onclick="setCheckboxes(\'usersForm\', \'selected_usr\', false); return false;">' . $strUncheckAll . '</a>' . "\n"
802 . ' </td>' . "\n"
803 . ' </tr>' . "\n"
804 . ' </table>' . "\n"
805 . ' <ul>' . "\n"
806 . ' <li>' . "\n"
807 . ' <b><a href="server_privileges.php3?' . $url_query . '&amp;adduser=1">' . $strAddUser . '</a></b><br />' . "\n"
808 . ' </li><br /><br />' . "\n"
809 . ' <li>' . "\n"
810 . ' <b>' . $strRemoveSelectedUsers . '</b><br>' . "\n"
811 . ' <input type="radio" title="' . $strJustDelete . ' ' . $strJustDeleteDescr . '" name="mode" id="radio_mode_1" value="1" checked="checked" />' . "\n"
812 . ' <label for="radio_mode_1" title="' . $strJustDelete . ' ' . $strJustDeleteDescr . '">' . "\n"
813 . ' ' . $strJustDelete . "\n"
814 . ' </label><br />' . "\n";
815 if (PMA_MYSQL_INT_VERSION >= 32304) {
816 echo ' <input type="radio" title="' . $strRevokeAndDelete . ' ' . $strRevokeAndDeleteDescr . '" name="mode" id="radio_mode_2" value="2" />' . "\n"
817 . ' <label for="radio_mode_2" title="' . $strRevokeAndDelete . ' ' . $strRevokeAndDeleteDescr . '">' . "\n"
818 . ' ' . $strRevokeAndDelete . "\n"
819 . ' </label><br />' . "\n";
821 echo ' <input type="radio" title="' . $strDeleteAndFlush . ' ' . $strDeleteAndFlushDescr . '" name="mode" id="radio_mode_3" value="3" />' . "\n"
822 . ' <label for="radio_mode_3" title="' . $strDeleteAndFlush . ' ' . $strDeleteAndFlushDescr . '">' . "\n"
823 . ' ' . $strDeleteAndFlush . "\n"
824 . ' </label><br />' . "\n"
825 . ' <input type="checkbox" title="' . $strDropUsersDb . '" name="drop_users_db" id="checkbox_drop_users_db" />' . "\n"
826 . ' <label for="checkbox_drop_users_db" title="' . $strDropUsersDb . '">' . "\n"
827 . ' ' . $strDropUsersDb . "\n"
828 . ' </label><br />' . "\n"
829 . ' <input type="submit" name="delete" value="' . $strGo . '" />' . "\n"
830 . ' </li>' . "\n"
831 . ' </ul>' . "\n"
832 . '</form>' . "\n"
833 . '<div>' . "\n"
834 . ' ' . sprintf($strFlushPrivilegesNote, '<a href="server_privileges.php3?' . $url_query . '&amp;flush_privileges=1">', '</a>') . "\n"
835 . '</div>' . "\n";
837 } else {
838 // A user was selected -> display the user's properties
839 if (!isset($hostname)) {
840 $hostname = '%';
842 echo '<h2>' . "\n"
843 . ' ' . $strUser . ' <i><a class="h2" href="server_privileges.php3?' . $url_query . '&amp;username=' . urlencode($username) . ($hostname == '%' ? '' : '&amp;hostname=' . urlencode($hostname)) . '">\'' . htmlspecialchars($username) . '\'@\'' . htmlspecialchars($hostname) . '\'</a></i>' . "\n";
844 if (!empty($dbname)) {
845 echo ' - ' . $strDatabase . ' <i><a class="h2" href="' . $cfg['DefaultTabDatabase'] . '?' . $url_query . '&amp;db=' . urlencode($dbname) . '&amp;reload=1">' . htmlspecialchars($dbname) . '</a></i>' . "\n";
846 if (!empty($tablename)) {
847 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";
850 echo '</h2>' . "\n";
851 $res = PMA_mysql_query('SELECT "foo" FROM `user` WHERE `User` = "' . $username . '" AND `Host` = "' . $hostname . '";', $userlink);
852 if (mysql_affected_rows($userlink) <= 0) {
853 echo $strUserNotFound;
854 include('./footer.inc.php3');
855 exit;
857 mysql_free_result($res);
858 unset($res);
859 echo '<ul>' . "\n"
860 . ' <li>' . "\n"
861 . ' <form action="server_privileges.php3" method="post">' . "\n"
862 . PMA_generate_common_hidden_inputs('', '', 3)
863 . ' <input type="hidden" name="username" value="' . htmlspecialchars($username) . '" />' . "\n";
864 if ($hostname != '%') {
865 echo ' <input type="hidden" name="hostname" value="' . htmlspecialchars($hostname) . '" />' . "\n";
867 if (!empty($dbname)) {
868 echo ' <input type="hidden" name="dbname" value="' . htmlspecialchars($dbname) . '" />' . "\n";
869 if (!empty($tablename)) {
870 echo ' <input type="hidden" name="tablename" value="' . htmlspecialchars($tablename) . '" />' . "\n";
873 echo ' <b>' . $strEditPrivileges . '</b><br />' . "\n";
874 PMA_displayPrivTable((empty($dbname) ? '*' : $dbname), ((empty($dbname) || empty($tablename)) ? '*' : $tablename), TRUE, 3);
875 echo ' </form>' . "\n"
876 . ' </li>' . "\n";
877 if (empty($tablename)) {
878 echo ' <li>' . "\n"
879 . ' <b>' . (empty($dbname) ? $strDbPrivileges : $strTblPrivileges) . '</b><br />' . "\n"
880 . ' <table border="0">' . "\n"
881 . ' <tr>' . "\n"
882 . ' <th>&nbsp;' . (empty($dbname) ? $strDatabase : $strTable) . '&nbsp;</th>' . "\n"
883 . ' <th>&nbsp;' . $strPrivileges . '&nbsp;</th>' . "\n";
884 if (PMA_MYSQL_INT_VERSION >= 32211) {
885 echo ' <th>&nbsp;' . $strGrantOption . '&nbsp;</th>' . "\n";
887 echo ' <th>&nbsp;' . (empty($dbname) ? $strTblPrivileges : $strColumnPrivileges) . '&nbsp;</th>' . "\n"
888 . ' <th colspan="2">&nbsp;' . $strAction . '&nbsp;</th>' . "\n"
889 . ' </tr>' . "\n";
890 if (empty($dbname)) {
891 $sql_query = 'SELECT * FROM `db` WHERE `Host` = "' . $hostname . '" AND `User` = "' . $username . '" ORDER BY `Db` ASC;';
892 } else {
893 $sql_query = 'SELECT `Table_name`, `Table_priv`, IF(`Column_priv` = "", 0, 1) AS "Column_priv" FROM `tables_priv` WHERE `Host` = "' . $hostname . '" AND `User` = "' . $username . '" AND `Db` = "' . $dbname . '" ORDER BY `Table_name` ASC;';
895 $res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
896 if (mysql_affected_rows($userlink) == 0) {
897 echo ' <tr>' . "\n"
898 . ' <td bgcolor="' . $cfg['BgcolorOne'] . '" colspan="' .(PMA_MYSQL_INT_VERSION >= 32211 ? '6' : '5') . '"><center><i>' . $strNone . '</i></center></td>' . "\n"
899 . ' </tr>' . "\n";
900 } else {
901 $useBgcolorOne = TRUE;
902 if (empty($dbname)) {
903 $res2 = PMA_mysql_query('SELECT `Db` FROM `tables_priv` WHERE `Host` = "' . $hostname . '" AND `User` = "' . $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` = "' . $username . '" GROUP BY `Db` ORDER BY `Db` ASC;');
904 $row2 = PMA_mysql_fetch_array($res2, MYSQL_ASSOC);
906 $found_rows = array();
907 while ($row = PMA_mysql_fetch_array($res, MYSQL_ASSOC)) {
908 while (empty($dbname) && $row2 && $row['Db'] > $row2['Db']) {
909 $found_rows[] = $row2['Db'];
910 echo ' <tr>' . "\n"
911 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . htmlspecialchars($row2['Db']) . '</td>' . "\n"
912 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><tt>' . "\n"
913 . ' <dfn title="' . $strPrivDescUsage . '">USAGE</dfn>' . "\n"
914 . ' </tt></td>' . "\n";
915 if (PMA_MYSQL_INT_VERSION >= 32211) {
916 echo ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . $strNo . '</td>' . "\n";
918 echo ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . $strYes . '</td>' . "\n"
919 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><a href="server_privileges.php3?' . $url_query . '&amp;username=' . urlencode($username) . ($hostname == '%' ? '' : '&amp;hostname=' . urlencode($hostname)) . '&amp;dbname=' . urlencode($row2['Db']) . '">' . $strEdit . '</a></td>' . "\n"
920 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><a href="server_privileges.php3?' . $url_query . '&amp;username=' . urlencode($username) . ($hostname == '%' ? '' : '&amp;hostname=' . urlencode($hostname)) . '&amp;dbname=' . urlencode($row2['Db']) . '&amp;revokeall=1">' . $strRevoke . '</a></td>' . "\n"
921 . ' </tr>' . "\n";
922 $row2 = PMA_mysql_fetch_array($res2, MYSQL_ASSOC);
923 $useBgcolorOne = !$useBgcolorOne;
924 } // end while
925 $found_rows[] = empty($dbname) ? $row['Db'] : $row['Table_name'];
926 echo ' <tr>' . "\n"
927 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . htmlspecialchars(empty($dbname) ? $row['Db'] : $row['Table_name']) . '</td>' . "\n"
928 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><tt>' . "\n"
929 . ' ' . join(',' . "\n" . ' ', PMA_extractPrivInfo($row, TRUE)) . "\n"
930 . ' </tt></td>' . "\n";
931 if (PMA_MYSQL_INT_VERSION >= 32211) {
932 echo ' <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";
934 echo ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">';
935 if ((empty($dbname) && $row2 && $row['Db'] == $row2['Db'])
936 || (!empty($dbname) && $row['Column_priv'])) {
937 echo $strYes;
938 if (empty($dbname)) {
939 $row2 = PMA_mysql_fetch_array($res2, MYSQL_ASSOC);
941 } else {
942 echo $strNo;
944 echo '</td>' . "\n"
945 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><a href="server_privileges.php3?' . $url_query . '&amp;username=' . urlencode($username) . ($hostname == '%' ? '' : '&amp;hostname=' . urlencode($hostname)) . '&amp;dbname=' . (empty($dbname) ? urlencode($row['Db']) : urlencode($dbname) . '&amp;tablename=' . urlencode($row['Table_name'])) . '">' . $strEdit . '</a></td>' . "\n"
946 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><a href="server_privileges.php3?' . $url_query . '&amp;username=' . urlencode($username) . ($hostname == '%' ? '' : '&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"
947 . ' </tr>' . "\n";
948 $useBgcolorOne = !$useBgcolorOne;
949 } // end while
950 while (empty($dbname) && $row2 = PMA_mysql_fetch_array($res2, MYSQL_ASSOC)) {
951 $found_rows[] = $row2['Db'];
952 echo ' <tr>' . "\n"
953 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . htmlspecialchars($row2['Db']) . '</td>' . "\n"
954 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><tt>' . "\n"
955 . ' <dfn title="' . $strPrivDescUsage . '">USAGE</dfn>' . "\n"
956 . ' </tt></td>' . "\n";
957 if (PMA_MYSQL_INT_VERSION >= 32211) {
958 echo ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . $strNo . '</td>' . "\n";
960 echo ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . $strYes . '</td>' . "\n"
961 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><a href="server_privileges.php3?' . $url_query . '&amp;username=' . urlencode($username) . ($hostname == '%' ? '' : '&amp;hostname=' . urlencode($hostname)) . '&amp;dbname=' . urlencode($row2['Db']) . '">' . $strEdit . '</a></td>' . "\n"
962 . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '"><a href="server_privileges.php3?' . $url_query . '&amp;username=' . urlencode($username) . ($hostname == '%' ? '' : '&amp;hostname=' . urlencode($hostname)) . '&amp;dbname=' . urlencode($row2['Db']) . '&amp;revokeall=1">' . $strRevoke . '</a></td>' . "\n"
963 . ' </tr>' . "\n";
964 $row2 = PMA_mysql_fetch_array($res2, MYSQL_ASSOC);
965 $useBgcolorOne = !$useBgcolorOne;
966 } // end while
967 if (empty($dbname)) {
968 mysql_free_result($res2);
969 unset($res2);
970 unset($row2);
973 mysql_free_result($res);
974 unset($res);
975 unset($row);
976 echo ' <tr>' . "\n"
977 . ' <td colspan="' .(PMA_MYSQL_INT_VERSION >= 32211 ? '5' : '4') . '">' . "\n"
978 . ' <form action="server_privileges.php3" method="post">' . "\n"
979 . PMA_generate_common_hidden_inputs('', '', 6)
980 . ' <input type="hidden" name="username" value="' . htmlspecialchars($username) . '" />' . "\n";
981 if ($hostname != '%') {
982 echo ' <input type="hidden" name="hostname" value="' . htmlspecialchars($hostname) . '" />' . "\n";
984 if (empty($dbname)) {
985 echo ' <label for="text_dbname">' . $strAddPrivilegesOnDb . ':</label>' . "\n";
986 $res = PMA_mysql_query('SHOW DATABASES;', $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), 'SHOW DATABASES;');
987 $pred_db_array = array();
988 while ($row = PMA_mysql_fetch_row($res)) {
989 if (!isset($found_rows) || !in_array($row[0], $found_rows)) {
990 $pred_db_array[] = $row[0];
993 mysql_free_result($res);
994 unset($res);
995 unset($row);
996 if (!empty($pred_db_array)) {
997 echo ' <select name="pred_dbname" class="textfield" onchange="this.form.submit();">' . "\n"
998 . ' <option value="" selected="selected">' . $strUseTextField . ':</option>' . "\n";
999 while (list(, $current_db) = each($pred_db_array)) {
1000 echo ' <option value="' . htmlspecialchars($current_db) . '">' . htmlspecialchars($current_db) . '</option>' . "\n";
1002 echo ' </select>' . "\n";
1004 echo ' <input type="text" id="text_dbname" name="dbname" class="textfield" />' . "\n";
1005 } else {
1006 echo ' <input type="hidden" name="dbname" value="' . htmlspecialchars($dbname) . '"/>' . "\n"
1007 . ' <label for="text_tablename">' . $strAddPrivilegesOnTbl . ':</label>' . "\n";
1008 if ($res = @PMA_mysql_query('SHOW TABLES FROM ' . PMA_backquote($dbname) . ';', $userlink)) {
1009 $pred_tbl_array = array();
1010 while ($row = PMA_mysql_fetch_row($res)) {
1011 if (!isset($found_rows) || !in_array($row[0], $found_rows)) {
1012 $pred_tbl_array[] = $row[0];
1015 mysql_free_result($res);
1016 unset($res);
1017 unset($row);
1018 if (!empty($pred_tbl_array)) {
1019 echo ' <select name="pred_tablename" class="textfield" onchange="this.form.submit();">' . "\n"
1020 . ' <option value="" selected="selected">' . $strUseTextField . ':</option>' . "\n";
1021 while (list(, $current_table) = each($pred_tbl_array)) {
1022 echo ' <option value="' . htmlspecialchars($current_table) . '">' . htmlspecialchars($current_table) . '</option>' . "\n";
1024 echo ' </select>' . "\n";
1026 } else {
1027 unset($res);
1029 echo ' <input type="text" id="text_tablename" name="tablename" class="textfield" />' . "\n";
1031 echo ' <input type="submit" value="' . $strGo . '" />' . "\n"
1032 . ' </form>' . "\n"
1033 . ' </td>' . "\n"
1034 . ' </tr>' . "\n"
1035 . ' </table><br />' . "\n"
1036 . ' </li>' . "\n";
1038 if (empty($dbname)) {
1039 echo ' <li>' . "\n"
1040 . ' <form action="server_privileges.php3" method="post" onsubmit="checkPassword(this);">' . "\n"
1041 . PMA_generate_common_hidden_inputs('', '', 3)
1042 . ' <input type="hidden" name="username" value="' . htmlspecialchars($username) . '" />' . "\n";
1043 if ($hostname != '%') {
1044 echo ' <input type="hidden" name="hostname" value="' . htmlspecialchars($hostname) . '" />' . "\n";
1046 echo ' <b>' . $strChangePassword . '</b><br />' . "\n"
1047 . ' <table border="0">' . "\n"
1048 . ' <tr>' . "\n"
1049 . ' <td bgcolor="' . $cfg['BgcolorOne'] . '"><input type="radio" name="nopass" value="1" id="radio_nopass_1" onclick="pma_pw.value=\'\'; pma_pw2.value=\'\';" /></td>' . "\n"
1050 . ' <td bgcolor="' . $cfg['BgcolorOne'] . '" colspan="2"><label for="radio_nopass_1">' . $strNoPassword . '</label></td>' . "\n"
1051 . ' </tr>' . "\n"
1052 . ' <tr>' . "\n"
1053 . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><input type="radio" name="nopass" value="0" id="radio_nopass_0" onclick="document.getElementById(\'pw_pma_pw\').focus();" /></td>' . "\n"
1054 . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><label for="radio_nopass_0">' . $strPassword . ':</label></td>' . "\n"
1055 . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><input type="password" name="pma_pw" id="pw_pma_pw" class="textfield" onchange="nopass[1].checked = true;" /></td>' . "\n"
1056 . ' </tr>' . "\n"
1057 . ' <tr>' . "\n"
1058 . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">&nbsp;</td>' . "\n"
1059 . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><label for="pw_pma_pw2">' . $strReType . ':</label></td>' . "\n"
1060 . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '"><input type="password" name="pma_pw2" id="pw_pma_pw2" class="textfield" onchange="nopass[1].checked = true;" /></td>' . "\n"
1061 . ' </tr>' . "\n"
1062 . ' <tr>' . "\n"
1063 . ' <td colspan="3" align="center">' . "\n"
1064 . ' <input type="submit" name="change_pw" value="' . $strGo . '" />' . "\n"
1065 . ' </td>' . "\n"
1066 . ' </tr>' . "\n"
1067 . ' </table>' . "\n"
1068 . ' </form>' . "\n"
1069 . ' </li>' . "\n";
1071 echo '</ul>' . "\n";
1073 } else {
1074 // Add a new user
1075 echo '<h2>' . "\n"
1076 . ' ' . $strAddUser . "\n"
1077 . '</h2>' . "\n"
1078 . '<form action="server_privileges.php3" method="post" onsubmit="return checkAddUser(this);">' . "\n"
1079 . PMA_generate_common_hidden_inputs('', '', 1)
1080 . ' <table border="0">' . "\n"
1081 . ' <tr>' . "\n"
1082 . ' <th colspan="3">' . "\n"
1083 . ' ' . $strLoginInformation . "\n"
1084 . ' </th>' . "\n"
1085 . ' </tr>' . "\n"
1086 . ' <tr>' . "\n"
1087 . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n"
1088 . ' <label for="select_pred_username">' . "\n"
1089 . ' ' . $strUserName . ':' . "\n"
1090 . ' </label>' . "\n"
1091 . ' </td>' . "\n"
1092 . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
1093 . ' <select name="pred_username" id="select_pred_username" title="' . $strUserName . '" class="textfield"' . "\n"
1094 . ' onchange="if (this.value == \'any\') { username.value = \'\'; } else if (this.value == \'userdefined\') { username.focus(); username.select(); }">' . "\n"
1095 . ' <option value="any"' . ((isset($pred_username) && $pred_username == 'any') ? ' selected="selected"' : '') . '>' . $strAnyUser . '</option>' . "\n"
1096 . ' <option value="userdefined"' . ((!isset($pred_username) || $pred_username == 'userdefined') ? ' selected="selected"' : '') . '>' . $strUseTextField . ':</option>' . "\n"
1097 . ' </select>' . "\n"
1098 . ' </td>' . "\n"
1099 . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
1100 . ' <input type="text" name="username" class="textfield" title="' . $strUserName . '"' . (empty($username) ? '' : ' value="' . $username . '"') . ' onchange="pred_username.value = \'userdefined\';" />' . "\n"
1101 . ' </td>' . "\n"
1102 . ' </tr>' . "\n"
1103 . ' <tr>' . "\n"
1104 . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n"
1105 . ' <label for="select_pred_hostname">' . "\n"
1106 . ' ' . $strHost . ':' . "\n"
1107 . ' </label>' . "\n"
1108 . ' </td>' . "\n"
1109 . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
1110 . ' <select name="pred_hostname" id="select_pred_hostname" title="' . $strHost . '" class="textfield"' . "\n";
1111 $res = PMA_mysql_query('SELECT USER();', $userlink);
1112 $row = @PMA_mysql_fetch_row($res);
1113 @mysql_free_result($res);
1114 unset($res);
1115 if (!empty($row[0])) {
1116 $thishost = str_replace("'", '', substr($row[0], (strrpos($row[0], '@') + 1)));
1117 if ($thishost == 'localhost' || $thishost == '127.0.0.1') {
1118 unset($thishost);
1121 echo ' onchange="if (this.value == \'any\') { hostname.value = \'%\'; } else if (this.value == \'localhost\') { hostname.value = \'localhost\'; } '
1122 . (empty($thishost) ? '' : 'else if (this.value == \'thishost\') { hostname.value = \'' . addslashes(htmlspecialchars($thishost)) . '\'; } ')
1123 . 'else if (this.value == \'userdefined\') { hostname.focus(); hostname.select(); }">' . "\n";
1124 unset($row);
1125 echo ' <option value="any"' . ((isset($pred_hostname) && $pred_hostname == 'any') ? ' selected="selected"' : '') . '>' . $strAnyHost . '</option>' . "\n"
1126 . ' <option value="localhost"' . ((isset($pred_hostname) && $pred_hostname == 'localhost') ? ' selected="selected"' : '') . '>' . $strLocalhost . '</option>' . "\n";
1127 if (!empty($thishost)) {
1128 echo ' <option value="thishost"' . ((isset($pred_hostname) && $pred_hostname == 'thishost') ? ' selected="selected"' : '') . '>' . $strThisHost . '</option>' . "\n";
1130 unset($thishost);
1131 echo ' <option value="userdefined"' . ((isset($pred_hostname) && $pred_hostname == 'userdefined') ? ' selected="selected"' : '') . '>' . $strUseTextField . ':</option>' . "\n"
1132 . ' </select>' . "\n"
1133 . ' </td>' . "\n"
1134 . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
1135 . ' <input type="text" name="hostname" value="' . (empty($hostname) ? '%' : $hostname) . '" class="textfield" title="' . $strHost . '" onchange="pred_hostname.value = \'userdefined\';" />' . "\n"
1136 . ' </td>' . "\n"
1137 . ' </tr>' . "\n"
1138 . ' <tr>' . "\n"
1139 . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n"
1140 . ' <label for="select_pred_password">' . "\n"
1141 . ' ' . $strPassword . ':' . "\n"
1142 . ' </label>' . "\n"
1143 . ' </td>' . "\n"
1144 . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
1145 . ' <select name="pred_password" id="select_pred_password" title="' . $strPassword . '" class="textfield"' . "\n"
1146 . ' onchange="if (this.value == \'none\') { pma_pw.value = \'\'; pma_pw2.value = \'\'; } else if (this.value == \'userdefined\') { pma_pw.focus(); pma_pw.select(); }">' . "\n"
1147 . ' <option value="none">' . $strNoPassword . '</option>' . "\n"
1148 . ' <option value="userdefined" selected="selected">' . $strUseTextField . ':</option>' . "\n"
1149 . ' </select>' . "\n"
1150 . ' </td>' . "\n"
1151 . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
1152 . ' <input type="password" name="pma_pw" class="textfield" title="' . $strPassword . '" onchange="pred_password.value = \'userdefined\';" />' . "\n"
1153 . ' </td>' . "\n"
1154 . ' </tr>' . "\n"
1155 . ' <tr>' . "\n"
1156 . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n"
1157 . ' <label for="text_pma_pw2">' . "\n"
1158 . ' ' . $strReType . ':' . "\n"
1159 . ' </label>' . "\n"
1160 . ' </td>' . "\n"
1161 . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">&nbsp;</td>' . "\n"
1162 . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
1163 . ' <input type="password" name="pma_pw2" id="text_pma_pw2" class="textfield" title="' . $strReType . '" onchange="pred_password.value = \'userdefined\';" />' . "\n"
1164 . ' </td>' . "\n"
1165 . ' </tr>' . "\n"
1166 . ' </table><br />' . "\n";
1167 PMA_displayPrivTable('*', '*', FALSE, 1);
1168 echo ' <br />' . "\n"
1169 . ' <input type="submit" name="adduser_submit" value="' . $strGo . '" />' . "\n"
1170 . '</form>' . "\n";
1171 } // end if (empty($adduser)) ... else ...
1175 * Displays the footer
1177 echo "\n\n";
1178 require('./footer.inc.php3');