Skip to content
Permalink
Browse files

Retrieve parameters from $_POST in import

Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
  • Loading branch information...
mauriciofauth committed Aug 17, 2018
1 parent 1edf1ac commit bf3e6c3a77ff5d1fc2a15bba7f0a66e7fcb357e6
Showing with 33 additions and 33 deletions.
  1. +29 −29 import.php
  2. +4 −4 libraries/classes/Import.php
@@ -29,12 +29,12 @@
*/
require_once 'libraries/common.inc.php';
if (isset($_REQUEST['show_as_php'])) {
$GLOBALS['show_as_php'] = $_REQUEST['show_as_php'];
if (isset($_POST['show_as_php'])) {
$GLOBALS['show_as_php'] = $_POST['show_as_php'];
}
// If there is a request to 'Simulate DML'.
if (isset($_REQUEST['simulate_dml'])) {
if (isset($_POST['simulate_dml'])) {
Import::handleSimulateDmlRequest();
exit;
}
@@ -44,25 +44,25 @@
$sql = new Sql();
// If it's a refresh console bookmarks request
if (isset($_REQUEST['console_bookmark_refresh'])) {
if (isset($_GET['console_bookmark_refresh'])) {
$response->addJSON(
'console_message_bookmark', PhpMyAdmin\Console::getBookmarkContent()
);
exit;
}
// If it's a console bookmark add request
if (isset($_REQUEST['console_bookmark_add'])) {
if (isset($_REQUEST['label']) && isset($_REQUEST['db'])
&& isset($_REQUEST['bookmark_query']) && isset($_REQUEST['shared'])
if (isset($_POST['console_bookmark_add'])) {
if (isset($_POST['label']) && isset($_POST['db'])
&& isset($_POST['bookmark_query']) && isset($_POST['shared'])
) {
$cfgBookmark = Bookmark::getParams($GLOBALS['cfg']['Server']['user']);
$bookmarkFields = array(
'bkm_database' => $_REQUEST['db'],
'bkm_database' => $_POST['db'],
'bkm_user' => $cfgBookmark['user'],
'bkm_sql_query' => $_REQUEST['bookmark_query'],
'bkm_label' => $_REQUEST['label']
'bkm_sql_query' => $_POST['bookmark_query'],
'bkm_label' => $_POST['label']
);
$isShared = ($_REQUEST['shared'] == 'true' ? true : false);
$isShared = ($_POST['shared'] == 'true' ? true : false);
$bookmark = Bookmark::createBookmark(
$GLOBALS['dbi'],
$GLOBALS['cfg']['Server']['user'],
@@ -124,11 +124,11 @@
if (! empty($sql_query)) {
// apply values for parameters
if (! empty($_REQUEST['parameterized'])
&& ! empty($_REQUEST['parameters'])
&& is_array($_REQUEST['parameters'])
if (! empty($_POST['parameterized'])
&& ! empty($_POST['parameters'])
&& is_array($_POST['parameters'])
) {
$parameters = $_REQUEST['parameters'];
$parameters = $_POST['parameters'];
foreach ($parameters as $parameter => $replacement) {
$quoted = preg_quote($parameter, '/');
// making sure that :param does not apply values to :param1
@@ -153,7 +153,7 @@
$_SESSION['sql_from_query_box'] = true;
// If there is a request to ROLLBACK when finished.
if (isset($_REQUEST['rollback_query'])) {
if (isset($_POST['rollback_query'])) {
Import::handleRollbackRequest($import_text);
}
@@ -191,7 +191,7 @@
$import_type = 'queryfile';
$format = 'sql';
unset($sql_file);
} elseif (! empty($_REQUEST['id_bookmark'])) {
} elseif (! empty($_POST['id_bookmark'])) {
// run bookmark
$import_type = 'query';
$format = 'sql';
@@ -305,7 +305,7 @@
}
$timestamp = time();
if (isset($_REQUEST['allow_interrupt'])) {
if (isset($_POST['allow_interrupt'])) {
$maximum_time = ini_get('max_execution_time');
} else {
$maximum_time = 0;
@@ -331,22 +331,22 @@
$msg = 'Sorry an unexpected error happened!';
// Bookmark Support: get a query back from bookmark if required
if (! empty($_REQUEST['id_bookmark'])) {
$id_bookmark = (int)$_REQUEST['id_bookmark'];
switch ($_REQUEST['action_bookmark']) {
if (! empty($_POST['id_bookmark'])) {
$id_bookmark = (int)$_POST['id_bookmark'];
switch ($_POST['action_bookmark']) {
case 0: // bookmarked query that have to be run
$bookmark = Bookmark::get(
$GLOBALS['dbi'],
$GLOBALS['cfg']['Server']['user'],
$db,
$id_bookmark,
'id',
isset($_REQUEST['action_bookmark_all'])
isset($_POST['action_bookmark_all'])
);
if (! empty($_REQUEST['bookmark_variable'])) {
if (! empty($_POST['bookmark_variable'])) {
$import_text = $bookmark->applyVariables(
$_REQUEST['bookmark_variable']
$_POST['bookmark_variable']
);
} else {
$import_text = $bookmark->getQuery();
@@ -383,7 +383,7 @@
$response->setRequestStatus($message->isSuccess());
$response->addJSON('message', $message);
$response->addJSON('sql_query', $import_text);
$response->addJSON('action_bookmark', $_REQUEST['action_bookmark']);
$response->addJSON('action_bookmark', $_POST['action_bookmark']);
exit;
} else {
$run_query = false;
@@ -404,7 +404,7 @@
);
$response->setRequestStatus($message->isSuccess());
$response->addJSON('message', $message);
$response->addJSON('action_bookmark', $_REQUEST['action_bookmark']);
$response->addJSON('action_bookmark', $_POST['action_bookmark']);
$response->addJSON('id_bookmark', $id_bookmark);
exit;
} else {
@@ -576,11 +576,11 @@
}
// Show correct message
if (! empty($id_bookmark) && $_REQUEST['action_bookmark'] == 2) {
if (! empty($id_bookmark) && $_POST['action_bookmark'] == 2) {
$message = PhpMyAdmin\Message::success(__('The bookmark has been deleted.'));
$display_query = $import_text;
$error = false; // unset error marker, it was used just to skip processing
} elseif (! empty($id_bookmark) && $_REQUEST['action_bookmark'] == 1) {
} elseif (! empty($id_bookmark) && $_POST['action_bookmark'] == 1) {
$message = PhpMyAdmin\Message::notice(__('Showing bookmark'));
} elseif ($bookmark_created) {
$special_message = '[br]' . sprintf(
@@ -779,6 +779,6 @@
}
// If there is request for ROLLBACK in the end.
if (isset($_REQUEST['rollback_query'])) {
if (isset($_POST['rollback_query'])) {
$GLOBALS['dbi']->query('ROLLBACK');
}
@@ -286,7 +286,7 @@ public static function runQuery($sql = '', $full = '', array &$sql_data = array(
$import_run_buffer = self::runQueryPost($import_run_buffer, $sql, $full);
// In case of ROLLBACK, notify the user.
if (isset($_REQUEST['rollback_query'])) {
if (isset($_POST['rollback_query'])) {
$msg .= __('[ROLLBACK occurred.]');
}
}
@@ -1343,7 +1343,7 @@ public static function handleSimulateDmlRequest()
$response = Response::getInstance();
$error = false;
$error_msg = __('Only single-table UPDATE and DELETE queries can be simulated.');
$sql_delimiter = $_REQUEST['sql_delimiter'];
$sql_delimiter = $_POST['sql_delimiter'];
$sql_data = array();
$queries = explode($sql_delimiter, $GLOBALS['sql_query']);
foreach ($queries as $sql_query) {
@@ -1565,7 +1565,7 @@ public static function executeMatchedRowQuery($matched_row_query)
*/
public static function handleRollbackRequest($sql_query)
{
$sql_delimiter = $_REQUEST['sql_delimiter'];
$sql_delimiter = $_POST['sql_delimiter'];
$queries = explode($sql_delimiter, $sql_query);
$error = false;
$error_msg = __(
@@ -1590,7 +1590,7 @@ public static function handleRollbackRequest($sql_query)
}
if ($error) {
unset($_REQUEST['rollback_query']);
unset($_POST['rollback_query']);
$response = Response::getInstance();
$message = Message::rawError($error);
$response->addJSON('message', $message);

0 comments on commit bf3e6c3

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