From eb13c69f0db2b1158d4b36deef7544fa1a932505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sat, 10 Nov 2018 16:46:24 -0200 Subject: [PATCH] Retrieve parameters from $_POST in server replication MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MaurĂ­cio Meneghini Fauth --- libraries/classes/ReplicationGui.php | 110 +++++++++++++-------------- libraries/replication.inc.php | 6 +- server_replication.php | 16 ++-- test/classes/ReplicationGuiTest.php | 6 +- 4 files changed, 66 insertions(+), 72 deletions(-) diff --git a/libraries/classes/ReplicationGui.php b/libraries/classes/ReplicationGui.php index 17e65dcfba..38155fbfa2 100644 --- a/libraries/classes/ReplicationGui.php +++ b/libraries/classes/ReplicationGui.php @@ -53,7 +53,7 @@ class ReplicationGui public static function getHtmlForMasterReplication() { $html = ''; - if (! isset($_REQUEST['repl_clear_scr'])) { + if (! isset($_POST['repl_clear_scr'])) { $html .= '
'; $html .= '' . __('Master replication') . ''; $html .= __('This server is configured as master in a replication process.'); @@ -72,16 +72,16 @@ class ReplicationGui $_url_params['mr_adduser'] = true; $_url_params['repl_clear_scr'] = true; - $html .= '
  • '; $html .= __('Add slave replication user') . '
  • '; } // Display 'Add replication slave user' form - if (isset($_REQUEST['mr_adduser'])) { + if (isset($_POST['mr_adduser'])) { $html .= self::getHtmlForReplicationMasterAddSlaveUser(); - } elseif (! isset($_REQUEST['repl_clear_scr'])) { + } elseif (! isset($_POST['repl_clear_scr'])) { $html .= ""; $html .= "
    "; } @@ -164,8 +164,8 @@ class ReplicationGui $html .= ' ' . ''; @@ -843,7 +839,7 @@ class ReplicationGui . '' . '' . Util::showHint( @@ -861,12 +857,12 @@ class ReplicationGui . ' ' . '' @@ -907,22 +903,22 @@ class ReplicationGui */ public static function handleControlRequest() { - if (isset($_REQUEST['sr_take_action'])) { + if (isset($_POST['sr_take_action'])) { $refresh = false; $result = false; $messageSuccess = null; $messageError = null; - if (isset($_REQUEST['slave_changemaster']) && ! $GLOBALS['cfg']['AllowArbitraryServer']) { + if (isset($_POST['slave_changemaster']) && ! $GLOBALS['cfg']['AllowArbitraryServer']) { $_SESSION['replication']['sr_action_status'] = 'error'; $_SESSION['replication']['sr_action_info'] = __('Connection to server is disabled, please enable $cfg[\'AllowArbitraryServer\'] in phpMyAdmin configuration.'); - } elseif (isset($_REQUEST['slave_changemaster'])) { + } elseif (isset($_POST['slave_changemaster'])) { $result = self::handleRequestForSlaveChangeMaster(); - } elseif (isset($_REQUEST['sr_slave_server_control'])) { + } elseif (isset($_POST['sr_slave_server_control'])) { $result = self::handleRequestForSlaveServerControl(); $refresh = true; - switch ($_REQUEST['sr_slave_action']) { + switch ($_POST['sr_slave_action']) { case 'start': $messageSuccess = __('Replication started successfully.'); $messageError = __('Error starting replication.'); @@ -940,7 +936,7 @@ class ReplicationGui $messageError = __('Error.'); break; } - } elseif (isset($_REQUEST['sr_slave_skip_error'])) { + } elseif (isset($_POST['sr_slave_skip_error'])) { $result = self::handleRequestForSlaveSkipError(); } @@ -974,13 +970,13 @@ class ReplicationGui { $sr = array(); $_SESSION['replication']['m_username'] = $sr['username'] - = $GLOBALS['dbi']->escapeString($_REQUEST['username']); + = $GLOBALS['dbi']->escapeString($_POST['username']); $_SESSION['replication']['m_password'] = $sr['pma_pw'] - = $GLOBALS['dbi']->escapeString($_REQUEST['pma_pw']); + = $GLOBALS['dbi']->escapeString($_POST['pma_pw']); $_SESSION['replication']['m_hostname'] = $sr['hostname'] - = $GLOBALS['dbi']->escapeString($_REQUEST['hostname']); + = $GLOBALS['dbi']->escapeString($_POST['hostname']); $_SESSION['replication']['m_port'] = $sr['port'] - = $GLOBALS['dbi']->escapeString($_REQUEST['text_port']); + = $GLOBALS['dbi']->escapeString($_POST['text_port']); $_SESSION['replication']['m_correct'] = ''; $_SESSION['replication']['sr_action_status'] = 'error'; $_SESSION['replication']['sr_action_info'] = __('Unknown error'); @@ -1043,10 +1039,10 @@ class ReplicationGui */ public static function handleRequestForSlaveServerControl() { - if (empty($_REQUEST['sr_slave_control_parm'])) { - $_REQUEST['sr_slave_control_parm'] = null; + if (empty($_POST['sr_slave_control_parm'])) { + $_POST['sr_slave_control_parm'] = null; } - if ($_REQUEST['sr_slave_action'] == 'reset') { + if ($_POST['sr_slave_action'] == 'reset') { $qStop = Replication::slaveControl("STOP"); $qReset = $GLOBALS['dbi']->tryQuery("RESET SLAVE;"); $qStart = Replication::slaveControl("START"); @@ -1056,8 +1052,8 @@ class ReplicationGui $qStart !== false && $qStart !== -1); } else { $qControl = Replication::slaveControl( - $_REQUEST['sr_slave_action'], - $_REQUEST['sr_slave_control_parm'] + $_POST['sr_slave_action'], + $_POST['sr_slave_control_parm'] ); $result = ($qControl !== false && $qControl !== -1); @@ -1074,8 +1070,8 @@ class ReplicationGui public static function handleRequestForSlaveSkipError() { $count = 1; - if (isset($_REQUEST['sr_skip_errors_count'])) { - $count = $_REQUEST['sr_skip_errors_count'] * 1; + if (isset($_POST['sr_skip_errors_count'])) { + $count = $_POST['sr_skip_errors_count'] * 1; } $qStop = Replication::slaveControl("STOP"); diff --git a/libraries/replication.inc.php b/libraries/replication.inc.php index d2d21a9b18..80a55869f4 100644 --- a/libraries/replication.inc.php +++ b/libraries/replication.inc.php @@ -19,7 +19,7 @@ $server_master_replication = $GLOBALS['dbi']->fetchResult('SHOW MASTER STATUS'); /** * set selected master server */ -if (! empty($_REQUEST['master_connection'])) { +if (! empty($_POST['master_connection'])) { /** * check for multi-master replication functionality */ @@ -30,10 +30,10 @@ if (! empty($_REQUEST['master_connection'])) { $GLOBALS['dbi']->query( "SET @@default_master_connection = '" . $GLOBALS['dbi']->escapeString( - $_REQUEST['master_connection'] + $_POST['master_connection'] ) . "'" ); - $GLOBALS['url_params']['master_connection'] = $_REQUEST['master_connection']; + $GLOBALS['url_params']['master_connection'] = $_POST['master_connection']; } } diff --git a/server_replication.php b/server_replication.php index 9ba60b41f9..48ea2582fc 100644 --- a/server_replication.php +++ b/server_replication.php @@ -40,10 +40,10 @@ if (! $GLOBALS['dbi']->isSuperuser()) { exit; } -// change $GLOBALS['url_params'] with $_REQUEST['url_params'] +// change $GLOBALS['url_params'] with $_POST['url_params'] // only if it is an array -if (isset($_REQUEST['url_params']) && is_array($_REQUEST['url_params'])) { - $GLOBALS['url_params'] = $_REQUEST['url_params']; +if (isset($_POST['url_params']) && is_array($_POST['url_params'])) { + $GLOBALS['url_params'] = $_POST['url_params']; } /** @@ -64,13 +64,13 @@ $response->addHTML(ReplicationGui::getHtmlForErrorMessage()); if ($GLOBALS['replication_info']['master']['status']) { $response->addHTML(ReplicationGui::getHtmlForMasterReplication()); -} elseif (! isset($_REQUEST['mr_configure']) - && ! isset($_REQUEST['repl_clear_scr']) +} elseif (! isset($_POST['mr_configure']) + && ! isset($_POST['repl_clear_scr']) ) { $response->addHTML(ReplicationGui::getHtmlForNotServerReplication()); } -if (isset($_REQUEST['mr_configure'])) { +if (isset($_POST['mr_configure'])) { // Render the 'Master configuration' section $response->addHTML(ReplicationGui::getHtmlForMasterConfiguration()); exit; @@ -78,7 +78,7 @@ if (isset($_REQUEST['mr_configure'])) { $response->addHTML(''); -if (! isset($_REQUEST['repl_clear_scr'])) { +if (! isset($_POST['repl_clear_scr'])) { // Render the 'Slave configuration' section $response->addHTML( ReplicationGui::getHtmlForSlaveConfiguration( @@ -87,6 +87,6 @@ if (! isset($_REQUEST['repl_clear_scr'])) { ) ); } -if (isset($_REQUEST['sl_configure'])) { +if (isset($_POST['sl_configure'])) { $response->addHTML(ReplicationGui::getHtmlForReplicationChangeMaster("slave_changemaster")); } diff --git a/test/classes/ReplicationGuiTest.php b/test/classes/ReplicationGuiTest.php index 3fd5e5cac8..f4a9459d1f 100644 --- a/test/classes/ReplicationGuiTest.php +++ b/test/classes/ReplicationGuiTest.php @@ -33,10 +33,8 @@ class ReplicationGuiTest extends TestCase */ public function setUp() { - //$_REQUEST - $_REQUEST['log'] = "index1"; - $_REQUEST['pos'] = 3; - $_REQUEST['mr_adduser'] = "mr_adduser"; + //$_POST + $_POST['mr_adduser'] = "mr_adduser"; //$GLOBALS $GLOBALS['cfg']['MaxRows'] = 10;