From ac272199168e30bd374e88feabc0ccaeb8b0dcc3 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Wed, 7 Mar 2012 13:12:46 -0500 Subject: [PATCH] Improve globalization code --- libraries/mult_submits.inc.php | 18 ++++---- server_privileges.php | 34 +++++++------- server_replication.php | 81 +++++++++++----------------------- 3 files changed, 51 insertions(+), 82 deletions(-) diff --git a/libraries/mult_submits.inc.php b/libraries/mult_submits.inc.php index 68f48e1424..59016d4a71 100644 --- a/libraries/mult_submits.inc.php +++ b/libraries/mult_submits.inc.php @@ -8,16 +8,16 @@ if (! defined('PHPMYADMIN')) { exit; } -if (isset($_REQUEST['table_type'])) { - $GLOBALS['table_type'] = $_REQUEST['table_type']; -} +$request_params = array( + 'selected_fld', + 'submit_mult', + 'table_type' +); -if (isset($_REQUEST['selected_fld'])) { - $GLOBALS['selected_fld'] = $_REQUEST['selected_fld']; -} - -if (isset($_REQUEST['submit_mult'])) { - $GLOBALS['submit_mult'] = $_REQUEST['submit_mult']; +foreach ($request_params as $one_request_param) { + if (isset($_REQUEST[$one_request_param])) { + $GLOBALS[$one_request_param] = $_REQUEST[$one_request_param]; + } } /** diff --git a/server_privileges.php b/server_privileges.php index 24a0aea808..e082ad565e 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -28,25 +28,25 @@ if ($GLOBALS['cfg']['AjaxEnable']) { $conditional_class = ''; } -if (isset($_GET['username'])) { - $GLOBALS['username'] = $_GET['username']; -} -if (isset($_GET['hostname'])) { - $GLOBALS['hostname'] = $_GET['hostname']; -} -if (isset($_GET['dbname'])) { - $GLOBALS['dbname'] = $_GET['dbname']; -} -if (isset($_GET['tablename'])) { - $GLOBALS['tablename'] = $_GET['tablename']; -} -if (isset($_GET['checkprivs'])) { - $GLOBALS['checkprivs'] = $_GET['checkprivs']; -} -if (isset($_GET['initial'])) { - $GLOBALS['initial'] = $_GET['initial']; +/** + * Sets globals from $_GET + */ + +$get_params = array( + 'checkprivs', + 'dbname', + 'hostname', + 'initial', + 'tablename', + 'username' +); +foreach ($get_params as $one_get_param) { + if (isset($_GET[$one_get_param])) { + $GLOBALS[$one_get_param] = $_GET[$one_get_param]; + } } + /** * Messages are built using the message name */ diff --git a/server_replication.php b/server_replication.php index 77e63e64dd..dc209d232b 100644 --- a/server_replication.php +++ b/server_replication.php @@ -37,62 +37,31 @@ if (! $is_superuser) { /** * Sets globals from $_REQUEST */ -if (isset($_REQUEST['hostname'])) { - $GLOBALS['hostname'] = $_REQUEST['hostname']; -} -if (isset($_REQUEST['mr_adduser'])) { - $GLOBALS['mr_adduser'] = $_REQUEST['mr_adduser']; -} -if (isset($_REQUEST['mr_configure'])) { - $GLOBALS['mr_configure'] = $_REQUEST['mr_configure']; -} -if (isset($_REQUEST['pma_pw'])) { - $GLOBALS['pma_pw'] = $_REQUEST['pma_pw']; -} -if (isset($_REQUEST['port'])) { - $GLOBALS['port'] = $_REQUEST['port']; -} -if (isset($_REQUEST['repl_clear_scr'])) { - $GLOBALS['repl_clear_scr'] = $_REQUEST['repl_clear_scr']; -} -if (isset($_REQUEST['repl_data'])) { - $GLOBALS['repl_data'] = $_REQUEST['repl_data']; -} -if (isset($_REQUEST['sl_configure'])) { - $GLOBALS['sl_configure'] = $_REQUEST['sl_configure']; -} -if (isset($_REQUEST['sl_sync'])) { - $GLOBALS['sl_sync'] = $_REQUEST['sl_sync']; -} -if (isset($_REQUEST['slave_changemaster'])) { - $GLOBALS['slave_changemaster'] = $_REQUEST['slave_changemaster']; -} -if (isset($_REQUEST['sr_skip_errors_count'])) { - $GLOBALS['sr_skip_errors_count'] = $_REQUEST['sr_skip_errors_count']; -} -if (isset($_REQUEST['sr_slave_action'])) { - $GLOBALS['sr_slave_action'] = $_REQUEST['sr_slave_action']; -} -if (isset($_REQUEST['sr_slave_control_parm'])) { - $GLOBALS['sr_slave_control_parm'] = $_REQUEST['sr_slave_control_parm']; -} -if (isset($_REQUEST['sr_slave_server_control'])) { - $GLOBALS['sr_slave_server_control'] = $_REQUEST['sr_slave_server_control']; -} -if (isset($_REQUEST['sr_slave_skip_error'])) { - $GLOBALS['sr_slave_skip_error'] = $_REQUEST['sr_slave_skip_error']; -} -if (isset($_REQUEST['sr_take_action'])) { - $GLOBALS['sr_take_action'] = $_REQUEST['sr_take_action']; -} -if (isset($_REQUEST['url_params'])) { - $GLOBALS['url_params'] = $_REQUEST['url_params']; -} -if (isset($_REQUEST['username'])) { - $GLOBALS['username'] = $_REQUEST['username']; -} -if (isset($_REQUEST[''])) { - $GLOBALS[''] = $_REQUEST['']; +$request_params = array( + 'hostname', + 'mr_adduser', + 'mr_configure', + 'pma_pw', + 'port', + 'repl_clear_scr', + 'repl_data', + 'sl_configure', + 'sl_sync', + 'slave_changemaster', + 'sr_skip_errors_count', + 'sr_slave_action', + 'sr_slave_control_parm', + 'sr_slave_server_control', + 'sr_slave_skip_error', + 'sr_take_action', + 'url_params', + 'username' +); + +foreach ($request_params as $one_request_param) { + if (isset($_REQUEST[$one_request_param])) { + $GLOBALS[$one_request_param] = $_REQUEST[$one_request_param]; + } } /**