summaryrefslogtreecommitdiff
blob: fafe170fb488afcf28c9cc01c11e5d26c1ad734a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
diff --exclude='*~' -urN phpMyAdmin-2.6.1-pl2.orig/server_privileges.php phpMyAdmin-2.6.1-pl2/server_privileges.php
--- phpMyAdmin-2.6.1-pl2.orig/server_privileges.php	2005-03-02 12:54:10.528575299 -0500
+++ phpMyAdmin-2.6.1-pl2/server_privileges.php	2005-03-02 12:55:47.977465714 -0500
@@ -490,6 +490,22 @@
        . (empty($thishost) ? '' : 'else if (this.value == \'thishost\') { hostname.value = \'' . addslashes(htmlspecialchars($thishost)) . '\'; } ')
        . 'else if (this.value == \'hosttable\') { hostname.value = \'\'; } else if (this.value == \'userdefined\') { hostname.focus(); hostname.select(); }">' . "\n";
     unset($row);
+
+    // when we start editing a user, $GLOBALS['pred_hostname'] is not defined
+    if (!isset($GLOBALS['pred_hostname']) && isset($GLOBALS['hostname'])) {
+        switch (strtolower($GLOBALS['hostname'])) {
+            case 'localhost':
+            case '127.0.0.1':
+                $GLOBALS['pred_hostname'] = 'localhost';
+                break;
+            case '%':
+                $GLOBALS['pred_hostname'] = 'any';
+                break;
+            default:
+                $GLOBALS['pred_hostname'] = 'userdefined';
+                break;
+        }        
+    }
     echo $spaces . '            <option value="any"' . ((isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'any') ? ' selected="selected"' : '') . '>' . $GLOBALS['strAnyHost'] . '</option>' . "\n"
        . $spaces . '            <option value="localhost"' . ((isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'localhost') ? ' selected="selected"' : '') . '>' . $GLOBALS['strLocalhost'] . '</option>' . "\n";
     if (!empty($thishost)) {
@@ -713,18 +729,33 @@
     // escaping a wildcard character in a GRANT is only accepted at the global
     // or database level, not at table level; this is why I remove
     // the escaping character
-    // Note: in the Database-specific privileges, we will have for example
+    // Note: in the phpMyAdmin list of Database-specific privileges,
+    //  we will have for example
     //  test\_db  SELECT (this one is for privileges on a db level)
     //  test_db   USAGE  (this one is for table-specific privileges)
     //
-    // It looks curious but reflects IMO the way MySQL works
+    // It looks curious but reflects the way MySQL works
+
+    if (empty($dbname)) {
+        $db_and_table = '*.*';
+    } else {
+        if (!empty($tablename)) {
+            $db_and_table = str_replace('\\','',PMA_backquote($dbname))
+                          . '.' . PMA_backquote($tablename);
+        } else {
+            // do not remove the escaping character when working at db level 
+            $db_and_table = PMA_backquote($dbname)
+                          . '.*'; 
+        }
+    }
+
 
-    $db_and_table = empty($dbname) ? '*.*' : str_replace('\\','',PMA_backquote($dbname)) . '.' . (empty($tablename) ? '*' : PMA_backquote($tablename));
     $sql_query0 = 'REVOKE ALL PRIVILEGES ON ' . $db_and_table . ' FROM \'' . PMA_sqlAddslashes($username) . '\'@\'' . $hostname . '\';';
     if (!isset($Grant_priv) || $Grant_priv != 'Y') {
         $sql_query1 = 'REVOKE GRANT OPTION ON ' . $db_and_table . ' FROM \'' . PMA_sqlAddslashes($username) . '\'@\'' . $hostname . '\';';
     }
     $sql_query2 = 'GRANT ' . join(', ', PMA_extractPrivInfo()) . ' ON ' . $db_and_table . ' TO \'' . PMA_sqlAddslashes($username) . '\'@\'' . $hostname . '\'';
+
     if ((isset($Grant_priv) && $Grant_priv == 'Y') || (empty($dbname) && PMA_MYSQL_INT_VERSION >= 40002 && (isset($max_questions) || isset($max_connections) || isset($max_updates)))) {
         $sql_query2 .= 'WITH';
         if (isset($Grant_priv) && $Grant_priv == 'Y') {