Merge remote-tracking branch 'origin/master'
[phpmyadmin.git] / import.php
blob9dc1e0ea34d7f6f6cd0c8c5bb10817923da6148b
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Core script for import, this is just the glue around all other stuff
6 * @package PhpMyAdmin
7 */
9 /**
10 * Get the variables sent or posted to this script and a core script
12 require_once 'libraries/common.inc.php';
13 require_once 'libraries/sql.lib.php';
14 require_once 'libraries/bookmark.lib.php';
15 require_once 'libraries/Console.class.php';
16 //require_once 'libraries/display_import_functions.lib.php';
18 if (isset($_REQUEST['show_as_php'])) {
19 $GLOBALS['show_as_php'] = $_REQUEST['show_as_php'];
22 // Import functions.
23 require_once 'libraries/import.lib.php';
25 // If there is a request to 'Simulate DML'.
26 if (isset($_REQUEST['simulate_dml'])) {
27 PMA_handleSimulateDMLRequest();
28 exit;
31 // If it's a refresh console bookmarks request
32 if (isset($_REQUEST['console_bookmark_refresh'])) {
33 $response = PMA_Response::getInstance();
34 $response->addJSON(
35 'console_message_bookmark', PMA_Console::getBookmarkContent()
37 exit;
39 // If it's a console bookmark add request
40 if (isset($_REQUEST['console_bookmark_add'])) {
41 $response = PMA_Response::getInstance();
42 if (isset($_REQUEST['label']) && isset($_REQUEST['db'])
43 && isset($_REQUEST['bookmark_query']) && isset($_REQUEST['shared'])
44 ) {
45 $cfgBookmark = PMA_Bookmark_getParams();
46 $bookmarkFields = array(
47 'bkm_database' => $_REQUEST['db'],
48 'bkm_user' => $cfgBookmark['user'],
49 'bkm_sql_query' => urlencode($_REQUEST['bookmark_query']),
50 'bkm_label' => $_REQUEST['label']
52 $isShared = ($_REQUEST['shared'] == 'true' ? true : false);
53 if (PMA_Bookmark_save($bookmarkFields, $isShared)) {
54 $response->addJSON('message', __('Succeeded'));
55 $response->addJSON('data', $bookmarkFields);
56 $response->addJSON('isShared', $isShared);
57 } else {
58 $response->addJSON('message', __('Failed'));
60 die();
61 } else {
62 $response->addJSON('message', __('Incomplete params'));
63 die();
67 /**
68 * Sets globals from $_POST
70 $post_params = array(
71 'bkm_label',
72 'charset_of_file',
73 'format',
74 'import_type',
75 'is_js_confirmed',
76 'MAX_FILE_SIZE',
77 'message_to_show',
78 'noplugin',
79 'skip_queries',
80 'local_import_file'
83 // TODO: adapt full list of allowed parameters, as in export.php
84 foreach ($post_params as $one_post_param) {
85 if (isset($_POST[$one_post_param])) {
86 $GLOBALS[$one_post_param] = $_POST[$one_post_param];
90 // reset import messages for ajax request
91 $_SESSION['Import_message']['message'] = null;
92 $_SESSION['Import_message']['go_back_url'] = null;
93 // default values
94 $GLOBALS['reload'] = false;
96 // Use to identify current cycle is executing
97 // a multiquery statement or stored routine
98 if (!isset($_SESSION['is_multi_query'])) {
99 $_SESSION['is_multi_query'] = false;
102 // Are we just executing plain query or sql file?
103 // (eg. non import, but query box/window run)
104 if (! empty($sql_query)) {
105 // run SQL query
106 $import_text = $sql_query;
107 $import_type = 'query';
108 $format = 'sql';
110 // If there is a request to ROLLBACK when finished.
111 if (isset($_REQUEST['rollback_query'])) {
112 PMA_handleRollbackRequest($import_text);
115 // refresh navigation and main panels
116 if (preg_match('/^(DROP)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i', $sql_query)) {
117 $GLOBALS['reload'] = true;
120 // refresh navigation panel only
121 if (preg_match(
122 '/^(CREATE|ALTER)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i',
123 $sql_query
124 )) {
125 $ajax_reload = array('reload' => true);
128 // do a dynamic reload if table is RENAMED
129 // (by sending the instruction to the AJAX response handler)
130 if (preg_match(
131 '/^RENAME\s+TABLE\s+(.*?)\s+TO\s+(.*?)($|;|\s)/i',
132 $sql_query,
133 $rename_table_names
134 )) {
135 $ajax_reload = array('reload' => true);
136 $ajax_reload['table_name'] = PMA_Util::unQuote($rename_table_names[2]);
139 $sql_query = '';
140 } elseif (! empty($sql_localfile)) {
141 // run SQL file on server
142 $local_import_file = $sql_localfile;
143 $import_type = 'queryfile';
144 $format = 'sql';
145 unset($sql_localfile);
146 } elseif (! empty($sql_file)) {
147 // run uploaded SQL file
148 $import_file = $sql_file;
149 $import_type = 'queryfile';
150 $format = 'sql';
151 unset($sql_file);
152 } elseif (! empty($_REQUEST['id_bookmark'])) {
153 // run bookmark
154 $import_type = 'query';
155 $format = 'sql';
158 // If we didn't get any parameters, either user called this directly, or
159 // upload limit has been reached, let's assume the second possibility.
160 if ($_POST == array() && $_GET == array()) {
161 $message = PMA_Message::error(
162 __('You probably tried to upload a file that is too large. Please refer to %sdocumentation%s for a workaround for this limit.')
164 $message->addParam('[doc@faq1-16]');
165 $message->addParam('[/doc]');
167 // so we can obtain the message
168 $_SESSION['Import_message']['message'] = $message->getDisplay();
169 $_SESSION['Import_message']['go_back_url'] = $GLOBALS['goto'];
171 $message->display();
172 exit; // the footer is displayed automatically
175 // Add console message id to response output
176 if (isset($_POST['console_message_id'])) {
177 $response = PMA_Response::getInstance();
178 $response->addJSON('console_message_id', $_POST['console_message_id']);
182 * Sets globals from $_POST patterns, for import plugins
183 * We only need to load the selected plugin
186 if (! in_array(
187 $format,
188 array(
189 'csv',
190 'ldi',
191 'mediawiki',
192 'ods',
193 'shp',
194 'sql',
195 'xml'
199 // this should not happen for a normal user
200 // but only during an attack
201 PMA_fatalError('Incorrect format parameter');
204 $post_patterns = array(
205 '/^force_file_/',
206 '/^' . $format . '_/'
209 PMA_setPostAsGlobal($post_patterns);
211 // Check needed parameters
212 PMA_Util::checkParameters(array('import_type', 'format'));
214 // We don't want anything special in format
215 $format = PMA_securePath($format);
216 /** @var PMA_String $pmaString */
217 $pmaString = $GLOBALS['PMA_String'];
219 // Create error and goto url
220 if ($import_type == 'table') {
221 $err_url = 'tbl_import.php' . PMA_URL_getCommon(
222 array(
223 'db' => $db, 'table' => $table
226 $_SESSION['Import_message']['go_back_url'] = $err_url;
227 $goto = 'tbl_import.php';
228 } elseif ($import_type == 'database') {
229 $err_url = 'db_import.php' . PMA_URL_getCommon(array('db' => $db));
230 $_SESSION['Import_message']['go_back_url'] = $err_url;
231 $goto = 'db_import.php';
232 } elseif ($import_type == 'server') {
233 $err_url = 'server_import.php' . PMA_URL_getCommon();
234 $_SESSION['Import_message']['go_back_url'] = $err_url;
235 $goto = 'server_import.php';
236 } else {
237 if (empty($goto) || !preg_match('@^(server|db|tbl)(_[a-z]*)*\.php$@i', $goto)) {
238 if (/*overload*/mb_strlen($table) && /*overload*/mb_strlen($db)) {
239 $goto = 'tbl_structure.php';
240 } elseif (/*overload*/mb_strlen($db)) {
241 $goto = 'db_structure.php';
242 } else {
243 $goto = 'server_sql.php';
246 if (/*overload*/mb_strlen($table) && /*overload*/mb_strlen($db)) {
247 $common = PMA_URL_getCommon(array('db' => $db, 'table' => $table));
248 } elseif (/*overload*/mb_strlen($db)) {
249 $common = PMA_URL_getCommon(array('db' => $db));
250 } else {
251 $common = PMA_URL_getCommon();
253 $err_url = $goto . $common
254 . (preg_match('@^tbl_[a-z]*\.php$@', $goto)
255 ? '&amp;table=' . htmlspecialchars($table)
256 : '');
257 $_SESSION['Import_message']['go_back_url'] = $err_url;
259 // Avoid setting selflink to 'import.php'
260 // problem similar to bug 4276
261 if (basename($_SERVER['SCRIPT_NAME']) === 'import.php') {
262 $_SERVER['SCRIPT_NAME'] = $goto;
266 if (/*overload*/mb_strlen($db)) {
267 $GLOBALS['dbi']->selectDb($db);
270 @set_time_limit($cfg['ExecTimeLimit']);
271 if (! empty($cfg['MemoryLimit'])) {
272 @ini_set('memory_limit', $cfg['MemoryLimit']);
275 $timestamp = time();
276 if (isset($_REQUEST['allow_interrupt'])) {
277 $maximum_time = ini_get('max_execution_time');
278 } else {
279 $maximum_time = 0;
282 // set default values
283 $timeout_passed = false;
284 $error = false;
285 $read_multiply = 1;
286 $finished = false;
287 $offset = 0;
288 $max_sql_len = 0;
289 $file_to_unlink = '';
290 $sql_query = '';
291 $sql_query_disabled = false;
292 $go_sql = false;
293 $executed_queries = 0;
294 $run_query = true;
295 $charset_conversion = false;
296 $reset_charset = false;
297 $bookmark_created = false;
299 // Bookmark Support: get a query back from bookmark if required
300 if (! empty($_REQUEST['id_bookmark'])) {
301 $id_bookmark = (int)$_REQUEST['id_bookmark'];
302 include_once 'libraries/bookmark.lib.php';
303 switch ($_REQUEST['action_bookmark']) {
304 case 0: // bookmarked query that have to be run
305 $import_text = PMA_Bookmark_get(
306 $db,
307 $id_bookmark,
308 'id',
309 isset($_REQUEST['action_bookmark_all'])
311 if (! empty($_REQUEST['bookmark_variable'])) {
312 $import_text = preg_replace(
313 '|/\*(.*)\[VARIABLE\](.*)\*/|imsU',
314 '${1}' . PMA_Util::sqlAddSlashes($_REQUEST['bookmark_variable']) . '${2}',
315 $import_text
319 // refresh navigation and main panels
320 if (preg_match(
321 '/^(DROP)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i',
322 $import_text
323 )) {
324 $GLOBALS['reload'] = true;
327 // refresh navigation panel only
328 if (preg_match(
329 '/^(CREATE|ALTER)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i',
330 $import_text
333 if (! isset($ajax_reload)) {
334 $ajax_reload = array();
336 $ajax_reload['reload'] = true;
338 break;
339 case 1: // bookmarked query that have to be displayed
340 $import_text = PMA_Bookmark_get($db, $id_bookmark);
341 if ($GLOBALS['is_ajax_request'] == true) {
342 $message = PMA_Message::success(__('Showing bookmark'));
343 $response = PMA_Response::getInstance();
344 $response->isSuccess($message->isSuccess());
345 $response->addJSON('message', $message);
346 $response->addJSON('sql_query', $import_text);
347 $response->addJSON('action_bookmark', $_REQUEST['action_bookmark']);
348 exit;
349 } else {
350 $run_query = false;
352 break;
353 case 2: // bookmarked query that have to be deleted
354 $import_text = PMA_Bookmark_get($db, $id_bookmark);
355 PMA_Bookmark_delete($id_bookmark);
356 if ($GLOBALS['is_ajax_request'] == true) {
357 $message = PMA_Message::success(__('The bookmark has been deleted.'));
358 $response = PMA_Response::getInstance();
359 $response->isSuccess($message->isSuccess());
360 $response->addJSON('message', $message);
361 $response->addJSON('action_bookmark', $_REQUEST['action_bookmark']);
362 $response->addJSON('id_bookmark', $id_bookmark);
363 exit;
364 } else {
365 $run_query = false;
366 $error = true; // this is kind of hack to skip processing the query
368 break;
370 } // end bookmarks reading
372 // Do no run query if we show PHP code
373 if (isset($GLOBALS['show_as_php'])) {
374 $run_query = false;
375 $go_sql = true;
378 // We can not read all at once, otherwise we can run out of memory
379 $memory_limit = trim(@ini_get('memory_limit'));
380 // 2 MB as default
381 if (empty($memory_limit)) {
382 $memory_limit = 2 * 1024 * 1024;
384 // In case no memory limit we work on 10MB chunks
385 if ($memory_limit == -1) {
386 $memory_limit = 10 * 1024 * 1024;
389 // Calculate value of the limit
390 $memoryUnit = /*overload*/mb_strtolower(substr($memory_limit, -1));
391 if ('m' == $memoryUnit) {
392 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024;
393 } elseif ('k' == $memoryUnit) {
394 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024;
395 } elseif ('g' == $memoryUnit) {
396 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024 * 1024;
397 } else {
398 $memory_limit = (int)$memory_limit;
401 // Just to be sure, there might be lot of memory needed for uncompression
402 $read_limit = $memory_limit / 8;
404 // handle filenames
405 if (isset($_FILES['import_file'])) {
406 $import_file = $_FILES['import_file']['tmp_name'];
408 if (! empty($local_import_file) && ! empty($cfg['UploadDir'])) {
410 // sanitize $local_import_file as it comes from a POST
411 $local_import_file = PMA_securePath($local_import_file);
413 $import_file = PMA_Util::userDir($cfg['UploadDir'])
414 . $local_import_file;
416 } elseif (empty($import_file) || ! is_uploaded_file($import_file)) {
417 $import_file = 'none';
420 // Do we have file to import?
422 if ($import_file != 'none' && ! $error) {
423 // work around open_basedir and other limitations
424 $open_basedir = @ini_get('open_basedir');
426 // If we are on a server with open_basedir, we must move the file
427 // before opening it.
429 if (! empty($open_basedir)) {
430 $tmp_subdir = ini_get('upload_tmp_dir');
431 if (empty($tmp_subdir)) {
432 $tmp_subdir = sys_get_temp_dir();
434 $tmp_subdir = rtrim($tmp_subdir, DIRECTORY_SEPARATOR);
435 if (is_writable($tmp_subdir)) {
436 $import_file_new = $tmp_subdir . DIRECTORY_SEPARATOR
437 . basename($import_file) . uniqid();
438 if (move_uploaded_file($import_file, $import_file_new)) {
439 $import_file = $import_file_new;
440 $file_to_unlink = $import_file_new;
443 $size = filesize($import_file);
444 } else {
446 // If the php.ini is misconfigured (eg. there is no /tmp access defined
447 // with open_basedir), $tmp_subdir won't be writable and the user gets
448 // a 'File could not be read!' error (at PMA_detectCompression), which
449 // is not too meaningful. Show a meaningful error message to the user
450 // instead.
452 $message = PMA_Message::error(
453 __('Uploaded file cannot be moved, because the server has open_basedir enabled without access to the %s directory (for temporary files).')
455 $message->addParam($tmp_subdir);
456 PMA_stopImport($message);
461 * Handle file compression
462 * @todo duplicate code exists in File.class.php
464 $compression = PMA_detectCompression($import_file);
465 if ($compression === false) {
466 $message = PMA_Message::error(__('File could not be read!'));
467 PMA_stopImport($message); //Contains an 'exit'
470 switch ($compression) {
471 case 'application/bzip2':
472 if ($cfg['BZipDump'] && @function_exists('bzopen')) {
473 $import_handle = @bzopen($import_file, 'r');
474 } else {
475 $message = PMA_Message::error(
476 __('You attempted to load file with unsupported compression (%s). Either support for it is not implemented or disabled by your configuration.')
478 $message->addParam($compression);
479 PMA_stopImport($message);
481 break;
482 case 'application/gzip':
483 if ($cfg['GZipDump'] && @function_exists('gzopen')) {
484 $import_handle = @gzopen($import_file, 'r');
485 } else {
486 $message = PMA_Message::error(
487 __('You attempted to load file with unsupported compression (%s). Either support for it is not implemented or disabled by your configuration.')
489 $message->addParam($compression);
490 PMA_stopImport($message);
492 break;
493 case 'application/zip':
494 if ($cfg['ZipDump'] && @function_exists('zip_open')) {
496 * Load interface for zip extension.
498 include_once 'libraries/zip_extension.lib.php';
499 $zipResult = PMA_getZipContents($import_file);
500 if (! empty($zipResult['error'])) {
501 $message = PMA_Message::rawError($zipResult['error']);
502 PMA_stopImport($message);
503 } else {
504 $import_text = $zipResult['data'];
506 } else {
507 $message = PMA_Message::error(
508 __('You attempted to load file with unsupported compression (%s). Either support for it is not implemented or disabled by your configuration.')
510 $message->addParam($compression);
511 PMA_stopImport($message);
513 break;
514 case 'none':
515 $import_handle = @fopen($import_file, 'r');
516 break;
517 default:
518 $message = PMA_Message::error(
519 __('You attempted to load file with unsupported compression (%s). Either support for it is not implemented or disabled by your configuration.')
521 $message->addParam($compression);
522 PMA_stopImport($message);
523 break;
525 // use isset() because zip compression type does not use a handle
526 if (! $error && isset($import_handle) && $import_handle === false) {
527 $message = PMA_Message::error(__('File could not be read!'));
528 PMA_stopImport($message);
530 } elseif (! $error) {
531 if (! isset($import_text) || empty($import_text)) {
532 $message = PMA_Message::error(
533 __('No data was received to import. Either no file name was submitted, or the file size exceeded the maximum size permitted by your PHP configuration. See [doc@faq1-16]FAQ 1.16[/doc].')
535 PMA_stopImport($message);
539 // so we can obtain the message
540 //$_SESSION['Import_message'] = $message->getDisplay();
542 // Convert the file's charset if necessary
543 if ($GLOBALS['PMA_recoding_engine'] != PMA_CHARSET_NONE && isset($charset_of_file)) {
544 if ($charset_of_file != 'utf-8') {
545 $charset_conversion = true;
547 } elseif (isset($charset_of_file) && $charset_of_file != 'utf-8') {
548 if (PMA_DRIZZLE) {
549 // Drizzle doesn't support other character sets,
550 // so we can't fallback to SET NAMES - throw an error
551 $message = PMA_Message::error(
553 'Cannot convert file\'s character'
554 . ' set without character set conversion library!'
557 PMA_stopImport($message);
558 } else {
559 $GLOBALS['dbi']->query('SET NAMES \'' . $charset_of_file . '\'');
560 // We can not show query in this case, it is in different charset
561 $sql_query_disabled = true;
562 $reset_charset = true;
566 // Something to skip?
567 if (! $error && isset($skip)) {
568 $original_skip = $skip;
569 while ($skip > 0) {
570 PMA_importGetNextChunk($skip < $read_limit ? $skip : $read_limit);
571 // Disable read progressivity, otherwise we eat all memory!
572 $read_multiply = 1;
573 $skip -= $read_limit;
575 unset($skip);
578 // This array contain the data like numberof valid sql queries in the statement
579 // and complete valid sql statement (which affected for rows)
580 $sql_data = array('valid_sql' => array(), 'valid_queries' => 0);
582 if (! $error) {
583 // Check for file existence
584 include_once "libraries/plugin_interface.lib.php";
585 $import_plugin = PMA_getPlugin(
586 "import",
587 $format,
588 'libraries/plugins/import/',
589 $import_type
591 if ($import_plugin == null) {
592 $message = PMA_Message::error(
593 __('Could not load import plugins, please check your installation!')
595 PMA_stopImport($message);
596 } else {
597 // Do the real import
598 $import_plugin->doImport($sql_data);
602 if (! empty($import_handle)) {
603 fclose($import_handle);
606 // Cleanup temporary file
607 if ($file_to_unlink != '') {
608 unlink($file_to_unlink);
611 // Reset charset back, if we did some changes
612 if ($reset_charset) {
613 $GLOBALS['dbi']->query('SET CHARACTER SET utf8');
614 $GLOBALS['dbi']->query(
615 'SET SESSION collation_connection =\'' . $collation_connection . '\''
619 // Show correct message
620 if (! empty($id_bookmark) && $_REQUEST['action_bookmark'] == 2) {
621 $message = PMA_Message::success(__('The bookmark has been deleted.'));
622 $display_query = $import_text;
623 $error = false; // unset error marker, it was used just to skip processing
624 } elseif (! empty($id_bookmark) && $_REQUEST['action_bookmark'] == 1) {
625 $message = PMA_Message::notice(__('Showing bookmark'));
626 } elseif ($bookmark_created) {
627 $special_message = '[br]' . sprintf(
628 __('Bookmark %s has been created.'),
629 htmlspecialchars($bkm_label)
631 } elseif ($finished && ! $error) {
632 if ($import_type == 'query') {
633 $message = PMA_Message::success();
634 } else {
635 $message = PMA_Message::success(
636 '<em>'
637 . __('Import has been successfully finished, %d queries executed.')
638 . '</em>'
640 $message->addParam($executed_queries);
642 if ($import_notice) {
643 $message->addString($import_notice);
645 if (isset($local_import_file)) {
646 $message->addString('(' . htmlspecialchars($local_import_file) . ')');
647 } else {
648 $message->addString(
649 '(' . htmlspecialchars($_FILES['import_file']['name']) . ')'
655 // Did we hit timeout? Tell it user.
656 if ($timeout_passed) {
657 $message = PMA_Message::error(
659 'Script timeout passed, if you want to finish import,'
660 . ' please resubmit same file and import will resume.'
663 if ($offset == 0 || (isset($original_skip) && $original_skip == $offset)) {
664 $message->addString(
666 'However on last run no data has been parsed,'
667 . ' this usually means phpMyAdmin won\'t be able to'
668 . ' finish this import unless you increase php time limits.'
674 // if there is any message, copy it into $_SESSION as well,
675 // so we can obtain it by AJAX call
676 if (isset($message)) {
677 $_SESSION['Import_message']['message'] = $message->getDisplay();
679 // Parse and analyze the query, for correct db and table name
680 // in case of a query typed in the query window
681 // (but if the query is too large, in case of an imported file, the parser
682 // can choke on it so avoid parsing)
683 $sqlLength = /*overload*/mb_strlen($sql_query);
684 if ($sqlLength <= $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
685 include_once 'libraries/parse_analyze.inc.php';
688 // There was an error?
689 if (isset($my_die)) {
690 foreach ($my_die as $key => $die) {
691 PMA_Util::mysqlDie(
692 $die['error'], $die['sql'], false, $err_url, $error
697 if ($go_sql) {
699 if (! empty($sql_data) && ($sql_data['valid_queries'] > 1)) {
700 $_SESSION['is_multi_query'] = true;
701 $sql_queries = $sql_data['valid_sql'];
702 } else {
703 $sql_queries = array($sql_query);
706 $html_output = '';
707 foreach ($sql_queries as $sql_query) {
708 // parse sql query
709 include 'libraries/parse_analyze.inc.php';
711 $html_output .= PMA_executeQueryAndGetQueryResponse(
712 $analyzed_sql_results, false, $db, $table, null,
713 $sql_query, null, $analyzed_sql_results['is_affected'],
714 null, null, null, $goto, $pmaThemeImage,
715 null, null, null, $sql_query, null, null
719 if (!isset($ajax_reload)) {
720 $ajax_reload = array();
722 if (isset($table)) {
723 $ajax_reload['table_name'] = $table;
725 $response = PMA_Response::getInstance();
726 $response->addJSON('ajax_reload', $ajax_reload);
727 $response->addHTML($html_output);
728 exit();
730 } else if ($result) {
731 // Save a Bookmark with more than one queries (if Bookmark label given).
732 if (! empty($_POST['bkm_label']) && ! empty($import_text)) {
733 $cfgBookmark = PMA_Bookmark_getParams();
734 PMA_storeTheQueryAsBookmark(
735 $db, $cfgBookmark['user'],
736 $import_text, $_POST['bkm_label'],
737 isset($_POST['bkm_replace']) ? $_POST['bkm_replace'] : null
741 $response = PMA_Response::getInstance();
742 $response->isSuccess(true);
743 $response->addJSON('message', PMA_Message::success($msg));
744 $response->addJSON(
745 'sql_query',
746 PMA_Util::getMessage($msg, $sql_query, 'success')
748 } else if ($result == false) {
749 $response = PMA_Response::getInstance();
750 $response->isSuccess(false);
751 $response->addJSON('message', PMA_Message::error($msg));
752 } else {
753 $active_page = $goto;
754 include '' . $goto;
757 // If there is request for ROLLBACK in the end.
758 if (isset($_REQUEST['rollback_query'])) {
759 $GLOBALS['dbi']->query('ROLLBACK');