improve PMA_getWithClauseForAddUserAndUpdatePrivs() function
This commit is contained in:
parent
f0dbcd4733
commit
800308a5f1
@ -1185,27 +1185,33 @@ function PMA_getMessageAndSqlQueryForPrivilegesRevoke($db_and_table, $dbname,
|
||||
*/
|
||||
function PMA_getWithClauseForAddUserAndUpdatePrivs()
|
||||
{
|
||||
$isWith = false;
|
||||
$sql_query = '';
|
||||
if (isset($_POST['Grant_priv']) && $_POST['Grant_priv'] == 'Y') {
|
||||
$sql_query .= ' GRANT OPTION';
|
||||
$isWith = true;
|
||||
}
|
||||
if (isset($_POST['max_questions'])) {
|
||||
$max_questions = max(0, (int)$_POST['max_questions']);
|
||||
$sql_query .= ' MAX_QUERIES_PER_HOUR ' . $max_questions;
|
||||
$isWith = true;
|
||||
}
|
||||
if (isset($_POST['max_connections'])) {
|
||||
$max_connections = max(0, (int)$_POST['max_connections']);
|
||||
$sql_query .= ' MAX_CONNECTIONS_PER_HOUR ' . $max_connections;
|
||||
$isWith = true;
|
||||
}
|
||||
if (isset($_POST['max_updates'])) {
|
||||
$max_updates = max(0, (int)$_POST['max_updates']);
|
||||
$sql_query .= ' MAX_UPDATES_PER_HOUR ' . $max_updates;
|
||||
$isWith = true;
|
||||
}
|
||||
if (isset($_POST['max_user_connections'])) {
|
||||
$max_user_connections = max(0, (int)$_POST['max_user_connections']);
|
||||
$sql_query .= ' MAX_USER_CONNECTIONS ' . $max_user_connections;
|
||||
$isWith = true;
|
||||
}
|
||||
return $sql_query;
|
||||
return ($isWith ? 'WITH' . $sql_query : $sql_query);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -279,11 +279,10 @@ if (isset($_REQUEST['adduser_submit']) || isset($_REQUEST['change_copy'])) {
|
||||
|| isset($max_updates) || isset($max_user_connections))
|
||||
) {
|
||||
$with_clause = PMA_getWithClauseForAddUserAndUpdatePrivs();
|
||||
$real_sql_query .= $with_clause;
|
||||
$sql_query .= $with_clause;
|
||||
}
|
||||
if (!empty ($with_clause)) {
|
||||
$real_sql_query .= 'WITH' . $with_clause;
|
||||
$sql_query .= 'WITH' . $with_clause;
|
||||
}
|
||||
|
||||
if (isset($create_user_real)) {
|
||||
$create_user_real .= ';';
|
||||
$create_user_show .= ';';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user