Skip to content
Permalink
Browse files

Retrieve parameters from $_POST in server_status_monitor.php

Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
  • Loading branch information...
mauriciofauth committed Nov 10, 2018
1 parent d1d90b5 commit a98207c6de3bde433602273d1cccc7f2f99d7501
@@ -686,7 +686,7 @@ AJAX.registerOnload('server_status_monitor.js', function () {
$.extend(vars, getvars); $.extend(vars, getvars);
} }


$.get('server_status_monitor.php' + PMA_commonParams.get('common_query'), vars, $.post('server_status_monitor.php' + PMA_commonParams.get('common_query'), vars,
function (data) { function (data) {
var logVars; var logVars;
if (typeof data !== 'undefined' && data.success === true) { if (typeof data !== 'undefined' && data.success === true) {
@@ -1591,9 +1591,10 @@ AJAX.registerOnload('server_status_monitor.js', function () {
buttons: dlgBtns buttons: dlgBtns
}); });



logRequest = $.post(
logRequest = $.get('server_status_monitor.php' + PMA_commonParams.get('common_query'), 'server_status_monitor.php' + PMA_commonParams.get('common_query'),
{ ajax_request: true, {
ajax_request: true,
log_data: 1, log_data: 1,
type: opts.src, type: opts.src,
time_start: Math.round(opts.start / 1000), time_start: Math.round(opts.start / 1000),
@@ -379,7 +379,7 @@ public static function getHtmlForClientSideDataAndLinks(Data $serverStatusData)
*/ */
public static function getJsonForChartingData() public static function getJsonForChartingData()
{ {
$ret = json_decode($_REQUEST['requiredData'], true); $ret = json_decode($_POST['requiredData'], true);
$statusVars = array(); $statusVars = array();
$serverVars = array(); $serverVars = array();
$sysinfo = $cpuload = $memory = 0; $sysinfo = $cpuload = $memory = 0;
@@ -633,7 +633,7 @@ public static function getJsonForLogDataTypeSlow($start, $end)
public static function getJsonForLogDataTypeGeneral($start, $end) public static function getJsonForLogDataTypeGeneral($start, $end)
{ {
$limitTypes = ''; $limitTypes = '';
if (isset($_REQUEST['limitTypes']) && $_REQUEST['limitTypes']) { if (isset($_POST['limitTypes']) && $_POST['limitTypes']) {
$limitTypes $limitTypes
= 'AND argument REGEXP \'^(INSERT|SELECT|UPDATE|DELETE)\' '; = 'AND argument REGEXP \'^(INSERT|SELECT|UPDATE|DELETE)\' ';
} }
@@ -652,8 +652,8 @@ public static function getJsonForLogDataTypeGeneral($start, $end)
$insertTables = array(); $insertTables = array();
$insertTablesFirst = -1; $insertTablesFirst = -1;
$i = 0; $i = 0;
$removeVars = isset($_REQUEST['removeVariables']) $removeVars = isset($_POST['removeVariables'])
&& $_REQUEST['removeVariables']; && $_POST['removeVariables'];
while ($row = $GLOBALS['dbi']->fetchAssoc($result)) { while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
preg_match('/^(\w+)\s/', $row['argument'], $match); preg_match('/^(\w+)\s/', $row['argument'], $match);
@@ -753,15 +753,15 @@ public static function getSuspensionPoints($lastChar)
*/ */
public static function getJsonForLoggingVars() public static function getJsonForLoggingVars()
{ {
if (isset($_REQUEST['varName']) && isset($_REQUEST['varValue'])) { if (isset($_POST['varName']) && isset($_POST['varValue'])) {
$value = $GLOBALS['dbi']->escapeString($_REQUEST['varValue']); $value = $GLOBALS['dbi']->escapeString($_POST['varValue']);
if (! is_numeric($value)) { if (! is_numeric($value)) {
$value="'" . $value . "'"; $value="'" . $value . "'";
} }
if (! preg_match("/[^a-zA-Z0-9_]+/", $_REQUEST['varName'])) { if (! preg_match("/[^a-zA-Z0-9_]+/", $_POST['varName'])) {
$GLOBALS['dbi']->query( $GLOBALS['dbi']->query(
'SET GLOBAL ' . $_REQUEST['varName'] . ' = ' . $value 'SET GLOBAL ' . $_POST['varName'] . ' = ' . $value
); );
} }
@@ -785,8 +785,8 @@ public static function getJsonForQueryAnalyzer()
{ {
$return = array(); $return = array();
if (strlen($_REQUEST['database']) > 0) { if (strlen($_POST['database']) > 0) {
$GLOBALS['dbi']->selectDb($_REQUEST['database']); $GLOBALS['dbi']->selectDb($_POST['database']);
} }
if ($profiling = Util::profilingSupported()) { if ($profiling = Util::profilingSupported()) {
@@ -797,7 +797,7 @@ public static function getJsonForQueryAnalyzer()
$query = preg_replace( $query = preg_replace(
'/^(\s*SELECT)/i', '/^(\s*SELECT)/i',
'\\1 SQL_NO_CACHE', '\\1 SQL_NO_CACHE',
$_REQUEST['query'] $_POST['query']
); );
$GLOBALS['dbi']->tryQuery($query); $GLOBALS['dbi']->tryQuery($query);
@@ -24,40 +24,40 @@
header('Content-Type: text/html; charset=UTF-8'); header('Content-Type: text/html; charset=UTF-8');
// real-time charting data // real-time charting data
if (isset($_REQUEST['chart_data'])) { if (isset($_POST['chart_data'])) {
switch($_REQUEST['type']) { switch($_POST['type']) {
case 'chartgrid': // Data for the monitor case 'chartgrid': // Data for the monitor
$ret = Monitor::getJsonForChartingData(); $ret = Monitor::getJsonForChartingData();
$response->addJSON('message', $ret); $response->addJSON('message', $ret);
exit; exit;
} }
} }
if (isset($_REQUEST['log_data'])) { if (isset($_POST['log_data'])) {
$start = intval($_REQUEST['time_start']); $start = intval($_POST['time_start']);
$end = intval($_REQUEST['time_end']); $end = intval($_POST['time_end']);
if ($_REQUEST['type'] == 'slow') { if ($_POST['type'] == 'slow') {
$return = Monitor::getJsonForLogDataTypeSlow($start, $end); $return = Monitor::getJsonForLogDataTypeSlow($start, $end);
$response->addJSON('message', $return); $response->addJSON('message', $return);
exit; exit;
} }
if ($_REQUEST['type'] == 'general') { if ($_POST['type'] == 'general') {
$return = Monitor::getJsonForLogDataTypeGeneral($start, $end); $return = Monitor::getJsonForLogDataTypeGeneral($start, $end);
$response->addJSON('message', $return); $response->addJSON('message', $return);
exit; exit;
} }
} }
if (isset($_REQUEST['logging_vars'])) { if (isset($_POST['logging_vars'])) {
$loggingVars = Monitor::getJsonForLoggingVars(); $loggingVars = Monitor::getJsonForLoggingVars();
$response->addJSON('message', $loggingVars); $response->addJSON('message', $loggingVars);
exit; exit;
} }
if (isset($_REQUEST['query_analyzer'])) { if (isset($_POST['query_analyzer'])) {
$return = Monitor::getJsonForQueryAnalyzer(); $return = Monitor::getJsonForQueryAnalyzer();
$response->addJSON('message', $return); $response->addJSON('message', $return);
exit; exit;
@@ -35,10 +35,6 @@ class MonitorTest extends TestCase
*/ */
public function setUp() public function setUp()
{ {
//$_REQUEST
$_REQUEST['log'] = "index1";
$_REQUEST['pos'] = 3;
//$GLOBALS //$GLOBALS
$GLOBALS['cfg']['MaxRows'] = 10; $GLOBALS['cfg']['MaxRows'] = 10;
$GLOBALS['cfg']['ServerDefault'] = "server"; $GLOBALS['cfg']['ServerDefault'] = "server";
@@ -282,7 +278,7 @@ public function testPMAGetJsonForLogDataTypeSlow()
*/ */
public function testPMAGetJsonForLogDataTypeGeneral() public function testPMAGetJsonForLogDataTypeGeneral()
{ {
$_REQUEST['limitTypes'] = true; $_POST['limitTypes'] = true;
//Mock DBI //Mock DBI
$dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface')
@@ -342,7 +338,7 @@ public function testPMAGetJsonForLogDataTypeGeneral()
*/ */
public function testPMAGetJsonForLoggingVars() public function testPMAGetJsonForLoggingVars()
{ {
$_REQUEST['varName'] = "varName"; $_POST['varName'] = "varName";
//Mock DBI //Mock DBI
$dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface')
@@ -377,8 +373,8 @@ public function testPMAGetJsonForLoggingVars()
*/ */
public function testPMAGetJsonForQueryAnalyzer() public function testPMAGetJsonForQueryAnalyzer()
{ {
$_REQUEST['database'] = "database"; $_POST['database'] = "database";
$_REQUEST['query'] = 'query'; $_POST['query'] = 'query';
$GLOBALS['server'] = 'server'; $GLOBALS['server'] = 'server';
$GLOBALS['cached_affected_rows'] = 'cached_affected_rows'; $GLOBALS['cached_affected_rows'] = 'cached_affected_rows';
$_SESSION['cache']['server_server']['profiling_supported'] = true; $_SESSION['cache']['server_server']['profiling_supported'] = true;

0 comments on commit a98207c

Please sign in to comment.
You can’t perform that action at this time.