Don't rely on $GLOBALS for 'Add User' form

This commit is contained in:
Jo Michael 2012-03-16 15:52:48 +01:00
parent a3511ff31d
commit 7d5a945a01

View File

@ -46,6 +46,44 @@ foreach ($get_params as $one_get_param) {
}
}
/**
* Sets globals from $_POST
*/
$post_params = array(
'createdb-1',
'createdb-2',
'createdb-3',
'grant_count',
'hostname',
'pma_pw',
'pma_pw2',
'pred_hostname',
'pred_password',
'pred_username',
'username'
);
foreach ($post_params as $one_post_param) {
if (isset($_POST[$one_post_param])) {
$GLOBALS[$one_post_param] = $_POST[$one_post_param];
}
}
/**
* Sets globals from $_POST patterns, for privileges and max_* vars
*/
$post_patterns = array(
'/_priv$/i',
'/^max_/i'
);
foreach (array_keys($_POST) as $post_key) {
foreach ($post_patterns as $one_post_pattern) {
if (preg_match($one_post_pattern, $post_key)) {
$GLOBALS[$post_key] = $_POST[$post_key];
}
}
}
/**
* Messages are built using the message name
@ -2282,15 +2320,15 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs
echo '<fieldset id="fieldset_add_user_database">' . "\n"
. '<legend>' . __('Database for user') . '</legend>' . "\n";
PMA_display_html_checkbox('createdb-1', __('Create database with same name and grant all privileges'), false, false);
echo '<br />' . "\n";
PMA_display_html_checkbox('createdb-2', __('Grant all privileges on wildcard name (username\\_%)'), false, false);
echo '<br />' . "\n";
PMA_display_html_checkbox('createdb-1', __('Create database with same name and grant all privileges'), false, false);
echo '<br />' . "\n";
PMA_display_html_checkbox('createdb-2', __('Grant all privileges on wildcard name (username\\_%)'), false, false);
echo '<br />' . "\n";
if (! empty($dbname) ) {
PMA_display_html_checkbox('createdb-3', sprintf(__('Grant all privileges on database &quot;%s&quot;'), htmlspecialchars($dbname)), true, false);
PMA_display_html_checkbox('createdb-3', sprintf(__('Grant all privileges on database &quot;%s&quot;'), htmlspecialchars($dbname)), true, false);
echo '<input type="hidden" name="dbname" value="' . htmlspecialchars($dbname) . '" />' . "\n";
echo '<br />' . "\n";
echo '<br />' . "\n";
}
echo '</fieldset>' . "\n";