\n"; if ($dbcheck) { echo "$strAction"; echo "$strHost"; echo "$strUser"; } else { echo "$strAction"; } echo "$strDatabase"; echo "$strTable"; echo "$strPrivileges"; if (!$dbcheck) echo "$strGrantOption"; echo "\n"; } function table_grants_tail() { echo "\n
"; } function table_grants($host, $user, $dbcheck = false) { global $cfgBgcolorOne, $cfgBgcolorTwo; global $server, $lang, $db, $table; global $self; global $strEdit, $strDelete, $strAny, $strAll, $strYes, $strNo; global $strRevoke, $strRevokePriv, $strRevokeGrant; global $strRevokeMessage, $strRevokeGrantMessage; global $strNoPrivileges; $select = "SHOW GRANTS FOR '$user'@'$host'"; $result = mysql_query($select); $rows = @mysql_num_rows($result); # Errors if (!isset($rows)) return -1; if ($rows == 0) return 0; $i = 0; while ($row = mysql_fetch_row($result)) { if (preg_match("/GRANT (.*) ON ([^\.]+).([^\.]+) TO .*$/i", $row[0], $parts)) { $priv = $parts[1]; $db = $parts[2]; $table = trim($parts[3]); $grantopt = eregi("WITH GRANT OPTION$", $row[0]); } else { $db = " "; $table = " "; $column = " "; $priv = ""; $grantopt = false; } if ($priv == "USAGE") $priv = ""; # Checking the database ... if ($dbcheck) if (!eregi($dbcheck . "|\*", $db) || (trim($priv) == "")) continue; # Password Line if ((trim($priv) == "") && !$grantopt) continue; if (!$dbcheck && !($show_header++)) table_grants_header(); $bgcolor = $cfgBgcolorOne; $i % 2 ? 0: $bgcolor = $cfgBgcolorTwo; # Revoke $query = "server=$server&lang=$lang&db=mysql&table=user"; $revoke_url = "sql.php3"; $revoke_url .= "?sql_query=".urlencode("REVOKE $priv ON ". db_name($db)."." . tbl_name($table) . " FROM '$user'@'$host'"); $revoke_url .= "&$query"; $revoke_url .= "&zero_rows=" . urlencode("$strRevokeMessage $user@$host"); $revoke_url .= "&goto=$self"; # Revoke GRANT OPTION $revoke_grant_url = "sql.php3"; $revoke_grant_url .= "?sql_query=" .urlencode("REVOKE GRANT OPTION ON ". db_name($db)."." . tbl_name($table) . " FROM '$user'@'$host'"); $revoke_grant_url .= "&$query"; $revoke_grant_url .= "&zero_rows=" . urlencode("$strRevokeGrantMessage $user@$host"); $revoke_grant_url .= "&goto=$self"; ?> > > > $strAny"; ?> $strAll" : $db; ?> $strAll" : $table; ?> $strNoPrivileges"; ?> "; else echo ""; echo ""; // echo ""; echo ""; if ($item % 2 == 0) echo "\n"; } if ($item % 2 == 1) echo "\n"; ?>
 " . ${"str$priv"} . "" . $priv . "
 
 
$user@$host
$strRememberReload"); $del_url .= "&server=$server&lang=$lang&db=mysql&table=user"; $del_url .= "&goto=$self"; ?>
" . $strEnglishPrivileges . "
"; echo "\n"; echo ""; echo ""; echo ""; echo ""; $i = 0; while ($row = mysql_fetch_array($result)) { $bgcolor = $cfgBgcolorOne; $i % 2 ? 0: $bgcolor = $cfgBgcolorTwo; $strPriv = ""; if ($row{"Select_priv"} == "Y") $strPriv .= "Select "; if ($row{"Insert_priv"} == "Y") $strPriv .= "Insert "; if ($row{"Update_priv"} == "Y") $strPriv .= "Update "; if ($row{"Delete_priv"} == "Y") $strPriv .= "Delete "; if ($row{"Create_priv"} == "Y") $strPriv .= "Create "; if ($row{"Drop_priv"} == "Y") $strPriv .= "Drop "; if ($row{"Reload_priv"} == "Y") $strPriv .= "Reload "; if ($row{"Shutdown_priv"} == "Y") $strPriv .= "Shutdown "; if ($row{"Process_priv"} == "Y") $strPriv .= "Process "; if ($row{"File_priv"} == "Y") $strPriv .= "File "; if ($row{"Grant_priv"} == "Y") $strPriv .= "Grant "; if ($row{"References_priv"} == "Y") $strPriv .= "References "; if ($row{"Index_priv"} == "Y") $strPriv .= "Index "; if ($row{"Alter_priv"} == "Y") $strPriv .= "Alter "; if ($strPriv == "") $strPriv = "$strNoPrivileges"; $query = "server=$server&lang=$lang&db=mysql&table=user"; # Edit $edit_url = $self; $edit_url .= "?server=$server&lang=$lang"; $edit_url .= "&edit=1&host=" . urlencode($row{"Host"}) . "&user=" . urlencode($row{"User"}); # Delete $delete_url = "$self?$query"; $delete_url .= "&delete=1&confirm=1&delete_host=" . urlencode($row{"Host"}) . "&delete_user=" . urlencode($row{"User"}); # Grants $check_url = $self; $check_url .= "?server=$server&lang=$lang"; $check_url .= "&grants=1&host=" . urlencode($row{"Host"}) . "&user=" . urlencode($row{"User"}); # $check_result = mysql_query("SHOW GRANTS FOR '" . $row{"User"} . "'@'" . $row{"Host"} ."'"); # if (@mysql_num_rows($check_result) == 0) $check_url = "" ?> \n
"; return $rows; } function confirm() { global $self, $server, $lang; global $strYes, $strNo, $strConfirm; ?> "; if ($host) echo "$strHost $host - $strUser "; echo ($user) ? $user : "$strAny"; echo ""; } # Confirm the action ... if (isset($confirm) && $confirm && !$clickyes) { confirm(); exit(); } if (($server > 0) && isset($mode) && ($mode == "reload")) { $result = mysql_query("FLUSH PRIVILEGES"); if ($result != 0) { echo "$strMySQLReloaded"; } else { echo "$strReloadFailed"; } } # Delete an user if (isset($delete) && $delete && isset($delete_host) && isset($delete_user)) { # Delete Grants First! mysql_query("DELETE FROM mysql.columns_priv WHERE host = '$delete_host' and user = '$delete_user'"); mysql_query("DELETE FROM mysql.db WHERE host = '$delete_host' and user = '$delete_user'"); mysql_query("DELETE FROM mysql.tables_priv WHERE host = '$delete_host' and user = '$delete_user'"); $result = mysql_query("DELETE FROM mysql.user WHERE host = '$delete_host' and user = '$delete_user'"); if ($result != 0) { echo "$strDeleteUserMessage $delete_user@$delete_host
$strRememberReload
"; } else { echo "$strDeleteFailed"; } } if (isset($edit) && $edit) { # Edit an user table_users($host, $user); edit_operations($host, $user); } elseif (isset($grants) && $grants) { # Revoke/Grant Privileges table_grants($host, $user); grant_operations(); } elseif (isset($check) && $check) { # Check Database Privileges check_db($db); check_operations(); } else { # Users actions if (!isset($host)) $host = false; if (!isset($user)) $user = false; table_users($host, $user) || mysql_die($strNoUsersFound); normal_operations(); } require("./footer.inc.php3"); ?>
$strAction"; echo "$strHost$strUser$strPassword$strPrivileges
" . $row{"User"}. "" : "$strAny"; ?> $strNo"; ?>