2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Core script for import, this is just the glue around all other stuff
8 use PMA\libraries\plugins\ImportPlugin
;
10 /* Enable LOAD DATA LOCAL INFILE for LDI plugin */
11 if (isset($_POST['format']) && $_POST['format'] == 'ldi') {
12 define('PMA_ENABLE_LDI', 1);
16 * Get the variables sent or posted to this script and a core script
18 require_once 'libraries/common.inc.php';
19 require_once 'libraries/sql.lib.php';
20 require_once 'libraries/bookmark.lib.php';
21 //require_once 'libraries/display_import_functions.lib.php';
23 if (isset($_REQUEST['show_as_php'])) {
24 $GLOBALS['show_as_php'] = $_REQUEST['show_as_php'];
28 require_once 'libraries/import.lib.php';
30 // If there is a request to 'Simulate DML'.
31 if (isset($_REQUEST['simulate_dml'])) {
32 PMA_handleSimulateDMLRequest();
36 // If it's a refresh console bookmarks request
37 if (isset($_REQUEST['console_bookmark_refresh'])) {
38 $response = PMA\libraries\Response
::getInstance();
40 'console_message_bookmark', PMA\libraries\Console
::getBookmarkContent()
44 // If it's a console bookmark add request
45 if (isset($_REQUEST['console_bookmark_add'])) {
46 $response = PMA\libraries\Response
::getInstance();
47 if (isset($_REQUEST['label']) && isset($_REQUEST['db'])
48 && isset($_REQUEST['bookmark_query']) && isset($_REQUEST['shared'])
50 $cfgBookmark = PMA_Bookmark_getParams();
51 $bookmarkFields = array(
52 'bkm_database' => $_REQUEST['db'],
53 'bkm_user' => $cfgBookmark['user'],
54 'bkm_sql_query' => $_REQUEST['bookmark_query'],
55 'bkm_label' => $_REQUEST['label']
57 $isShared = ($_REQUEST['shared'] == 'true' ?
true : false);
58 if (PMA_Bookmark_save($bookmarkFields, $isShared)) {
59 $response->addJSON('message', __('Succeeded'));
60 $response->addJSON('data', $bookmarkFields);
61 $response->addJSON('isShared', $isShared);
63 $response->addJSON('message', __('Failed'));
67 $response->addJSON('message', __('Incomplete params'));
75 * Sets globals from $_POST
89 // TODO: adapt full list of allowed parameters, as in export.php
90 foreach ($post_params as $one_post_param) {
91 if (isset($_POST[$one_post_param])) {
92 $GLOBALS[$one_post_param] = $_POST[$one_post_param];
96 // reset import messages for ajax request
97 $_SESSION['Import_message']['message'] = null;
98 $_SESSION['Import_message']['go_back_url'] = null;
100 $GLOBALS['reload'] = false;
102 // Use to identify current cycle is executing
103 // a multiquery statement or stored routine
104 if (!isset($_SESSION['is_multi_query'])) {
105 $_SESSION['is_multi_query'] = false;
108 $ajax_reload = array();
109 // Are we just executing plain query or sql file?
110 // (eg. non import, but query box/window run)
111 if (! empty($sql_query)) {
113 // apply values for parameters
114 if (! empty($_REQUEST['parameterized'])
115 && ! empty($_REQUEST['parameters'])
116 && is_array($_REQUEST['parameters'])) {
117 $parameters = $_REQUEST['parameters'];
118 foreach ($parameters as $parameter => $replacement) {
119 $quoted = preg_quote($parameter, '/');
120 // making sure that :param does not apply values to :param1
121 $sql_query = preg_replace(
122 '/' . $quoted . '([^a-zA-Z0-9_])/',
123 $GLOBALS['dbi']->escapeString($replacement) . '${1}',
126 // for parameters the appear at the end of the string
127 $sql_query = preg_replace(
128 '/' . $quoted . '$/',
129 $GLOBALS['dbi']->escapeString($replacement),
136 $import_text = $sql_query;
137 $import_type = 'query';
139 $_SESSION['sql_from_query_box'] = true;
141 // If there is a request to ROLLBACK when finished.
142 if (isset($_REQUEST['rollback_query'])) {
143 PMA_handleRollbackRequest($import_text);
146 // refresh navigation and main panels
147 if (preg_match('/^(DROP)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i', $sql_query)) {
148 $GLOBALS['reload'] = true;
149 $ajax_reload['reload'] = true;
152 // refresh navigation panel only
154 '/^(CREATE|ALTER)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i',
157 $ajax_reload['reload'] = true;
160 // do a dynamic reload if table is RENAMED
161 // (by sending the instruction to the AJAX response handler)
163 '/^RENAME\s+TABLE\s+(.*?)\s+TO\s+(.*?)($|;|\s)/i',
167 $ajax_reload['reload'] = true;
168 $ajax_reload['table_name'] = PMA\libraries\Util
::unQuote(
169 $rename_table_names[2]
174 } elseif (! empty($sql_file)) {
175 // run uploaded SQL file
176 $import_file = $sql_file;
177 $import_type = 'queryfile';
180 } elseif (! empty($_REQUEST['id_bookmark'])) {
182 $import_type = 'query';
186 // If we didn't get any parameters, either user called this directly, or
187 // upload limit has been reached, let's assume the second possibility.
188 if ($_POST == array() && $_GET == array()) {
189 $message = PMA\libraries\Message
::error(
191 'You probably tried to upload a file that is too large. Please refer ' .
192 'to %sdocumentation%s for a workaround for this limit.'
195 $message->addParam('[doc@faq1-16]');
196 $message->addParam('[/doc]');
198 // so we can obtain the message
199 $_SESSION['Import_message']['message'] = $message->getDisplay();
200 $_SESSION['Import_message']['go_back_url'] = $GLOBALS['goto'];
202 $response = PMA\libraries\Response
::getInstance();
203 $response->setRequestStatus(false);
204 $response->addJSON('message', $message);
206 exit; // the footer is displayed automatically
209 // Add console message id to response output
210 if (isset($_POST['console_message_id'])) {
211 $response = PMA\libraries\Response
::getInstance();
212 $response->addJSON('console_message_id', $_POST['console_message_id']);
216 * Sets globals from $_POST patterns, for import plugins
217 * We only need to load the selected plugin
233 // this should not happen for a normal user
234 // but only during an attack
235 PMA_fatalError('Incorrect format parameter');
238 $post_patterns = array(
240 '/^' . $format . '_/'
243 PMA_setPostAsGlobal($post_patterns);
245 // Check needed parameters
246 PMA\libraries\Util
::checkParameters(array('import_type', 'format'));
248 // We don't want anything special in format
249 $format = PMA_securePath($format);
251 // Create error and goto url
252 if ($import_type == 'table') {
253 $err_url = 'tbl_import.php' . PMA_URL_getCommon(
255 'db' => $db, 'table' => $table
258 $_SESSION['Import_message']['go_back_url'] = $err_url;
259 $goto = 'tbl_import.php';
260 } elseif ($import_type == 'database') {
261 $err_url = 'db_import.php' . PMA_URL_getCommon(array('db' => $db));
262 $_SESSION['Import_message']['go_back_url'] = $err_url;
263 $goto = 'db_import.php';
264 } elseif ($import_type == 'server') {
265 $err_url = 'server_import.php' . PMA_URL_getCommon();
266 $_SESSION['Import_message']['go_back_url'] = $err_url;
267 $goto = 'server_import.php';
269 if (empty($goto) ||
!preg_match('@^(server|db|tbl)(_[a-z]*)*\.php$@i', $goto)) {
270 if (mb_strlen($table) && mb_strlen($db)) {
271 $goto = 'tbl_structure.php';
272 } elseif (mb_strlen($db)) {
273 $goto = 'db_structure.php';
275 $goto = 'server_sql.php';
278 if (mb_strlen($table) && mb_strlen($db)) {
279 $common = PMA_URL_getCommon(array('db' => $db, 'table' => $table));
280 } elseif (mb_strlen($db)) {
281 $common = PMA_URL_getCommon(array('db' => $db));
283 $common = PMA_URL_getCommon();
285 $err_url = $goto . $common
286 . (preg_match('@^tbl_[a-z]*\.php$@', $goto)
287 ?
'&table=' . htmlspecialchars($table)
289 $_SESSION['Import_message']['go_back_url'] = $err_url;
291 // Avoid setting selflink to 'import.php'
292 // problem similar to bug 4276
293 if (basename($_SERVER['SCRIPT_NAME']) === 'import.php') {
294 $_SERVER['SCRIPT_NAME'] = $goto;
298 if (mb_strlen($db)) {
299 $GLOBALS['dbi']->selectDb($db);
302 @set_time_limit
($cfg['ExecTimeLimit']);
303 if (! empty($cfg['MemoryLimit'])) {
304 @ini_set
('memory_limit', $cfg['MemoryLimit']);
308 if (isset($_REQUEST['allow_interrupt'])) {
309 $maximum_time = ini_get('max_execution_time');
314 // set default values
315 $timeout_passed = false;
321 $file_to_unlink = '';
323 $sql_query_disabled = false;
325 $executed_queries = 0;
327 $charset_conversion = false;
328 $reset_charset = false;
329 $bookmark_created = false;
331 // Bookmark Support: get a query back from bookmark if required
332 if (! empty($_REQUEST['id_bookmark'])) {
333 $id_bookmark = (int)$_REQUEST['id_bookmark'];
334 include_once 'libraries/bookmark.lib.php';
335 switch ($_REQUEST['action_bookmark']) {
336 case 0: // bookmarked query that have to be run
337 $import_text = PMA_Bookmark_get(
341 isset($_REQUEST['action_bookmark_all'])
343 if (! empty($_REQUEST['bookmark_variable'])) {
344 $import_text = PMA_Bookmark_applyVariables(
349 // refresh navigation and main panels
351 '/^(DROP)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i',
354 $GLOBALS['reload'] = true;
355 $ajax_reload['reload'] = true;
358 // refresh navigation panel only
360 '/^(CREATE|ALTER)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i',
364 $ajax_reload['reload'] = true;
367 case 1: // bookmarked query that have to be displayed
368 $import_text = PMA_Bookmark_get($db, $id_bookmark);
369 if ($GLOBALS['is_ajax_request'] == true) {
370 $message = PMA\libraries\Message
::success(__('Showing bookmark'));
371 $response = PMA\libraries\Response
::getInstance();
372 $response->setRequestStatus($message->isSuccess());
373 $response->addJSON('message', $message);
374 $response->addJSON('sql_query', $import_text);
375 $response->addJSON('action_bookmark', $_REQUEST['action_bookmark']);
381 case 2: // bookmarked query that have to be deleted
382 $import_text = PMA_Bookmark_get($db, $id_bookmark);
383 PMA_Bookmark_delete($id_bookmark);
384 if ($GLOBALS['is_ajax_request'] == true) {
385 $message = PMA\libraries\Message
::success(
386 __('The bookmark has been deleted.')
388 $response = PMA\libraries\Response
::getInstance();
389 $response->setRequestStatus($message->isSuccess());
390 $response->addJSON('message', $message);
391 $response->addJSON('action_bookmark', $_REQUEST['action_bookmark']);
392 $response->addJSON('id_bookmark', $id_bookmark);
396 $error = true; // this is kind of hack to skip processing the query
400 } // end bookmarks reading
402 // Do no run query if we show PHP code
403 if (isset($GLOBALS['show_as_php'])) {
408 // We can not read all at once, otherwise we can run out of memory
409 $memory_limit = trim(@ini_get
('memory_limit'));
411 if (empty($memory_limit)) {
412 $memory_limit = 2 * 1024 * 1024;
414 // In case no memory limit we work on 10MB chunks
415 if ($memory_limit == -1) {
416 $memory_limit = 10 * 1024 * 1024;
419 // Calculate value of the limit
420 $memoryUnit = mb_strtolower(substr($memory_limit, -1));
421 if ('m' == $memoryUnit) {
422 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024;
423 } elseif ('k' == $memoryUnit) {
424 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024;
425 } elseif ('g' == $memoryUnit) {
426 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024 * 1024;
428 $memory_limit = (int)$memory_limit;
431 // Just to be sure, there might be lot of memory needed for uncompression
432 $read_limit = $memory_limit / 8;
435 if (isset($_FILES['import_file'])) {
436 $import_file = $_FILES['import_file']['tmp_name'];
438 if (! empty($local_import_file) && ! empty($cfg['UploadDir'])) {
440 // sanitize $local_import_file as it comes from a POST
441 $local_import_file = PMA_securePath($local_import_file);
443 $import_file = PMA\libraries\Util
::userDir($cfg['UploadDir'])
444 . $local_import_file;
447 * Do not allow symlinks to avoid security issues
448 * (user can create symlink to file he can not access,
449 * but phpMyAdmin can).
451 if (@is_link
($import_file)) {
452 $import_file = 'none';
455 } elseif (empty($import_file) ||
! is_uploaded_file($import_file)) {
456 $import_file = 'none';
459 // Do we have file to import?
461 if ($import_file != 'none' && ! $error) {
462 // work around open_basedir and other limitations
463 $open_basedir = @ini_get
('open_basedir');
465 // If we are on a server with open_basedir, we must move the file
466 // before opening it.
468 if (! empty($open_basedir)) {
469 $tmp_subdir = ini_get('upload_tmp_dir');
470 if (empty($tmp_subdir)) {
471 $tmp_subdir = sys_get_temp_dir();
473 $tmp_subdir = rtrim($tmp_subdir, DIRECTORY_SEPARATOR
);
474 if (@is_writable
($tmp_subdir)) {
475 $import_file_new = $tmp_subdir . DIRECTORY_SEPARATOR
476 . basename($import_file) . uniqid();
477 if (move_uploaded_file($import_file, $import_file_new)) {
478 $import_file = $import_file_new;
479 $file_to_unlink = $import_file_new;
482 $size = filesize($import_file);
485 // If the php.ini is misconfigured (eg. there is no /tmp access defined
486 // with open_basedir), $tmp_subdir won't be writable and the user gets
487 // a 'File could not be read!' error (at PMA_detectCompression), which
488 // is not too meaningful. Show a meaningful error message to the user
491 $message = PMA\libraries\Message
::error(
493 'Uploaded file cannot be moved, because the server has ' .
494 'open_basedir enabled without access to the %s directory ' .
495 '(for temporary files).'
498 $message->addParam($tmp_subdir);
499 PMA_stopImport($message);
504 * Handle file compression
505 * @todo duplicate code exists in File.php
507 $compression = PMA_detectCompression($import_file);
508 if ($compression === false) {
509 $message = PMA\libraries\Message
::error(__('File could not be read!'));
510 PMA_stopImport($message); //Contains an 'exit'
513 switch ($compression) {
514 case 'application/bzip2':
515 if ($cfg['BZipDump'] && @function_exists
('bzopen')) {
516 $import_handle = @bzopen
($import_file, 'r');
518 $message = PMA\libraries\Message
::error(
520 'You attempted to load file with unsupported compression ' .
521 '(%s). Either support for it is not implemented or disabled ' .
522 'by your configuration.'
525 $message->addParam($compression);
526 PMA_stopImport($message);
529 case 'application/gzip':
530 if ($cfg['GZipDump'] && @function_exists
('gzopen')) {
531 $import_handle = @gzopen
($import_file, 'r');
533 $message = PMA\libraries\Message
::error(
535 'You attempted to load file with unsupported compression ' .
536 '(%s). Either support for it is not implemented or disabled ' .
537 'by your configuration.'
540 $message->addParam($compression);
541 PMA_stopImport($message);
544 case 'application/zip':
545 if ($cfg['ZipDump'] && @function_exists
('zip_open')) {
547 * Load interface for zip extension.
549 include_once 'libraries/zip_extension.lib.php';
550 $zipResult = PMA_getZipContents($import_file);
551 if (! empty($zipResult['error'])) {
552 $message = PMA\libraries\Message
::rawError($zipResult['error']);
553 PMA_stopImport($message);
555 $import_text = $zipResult['data'];
558 $message = PMA\libraries\Message
::error(
560 'You attempted to load file with unsupported compression ' .
561 '(%s). Either support for it is not implemented or disabled ' .
562 'by your configuration.'
565 $message->addParam($compression);
566 PMA_stopImport($message);
570 $import_handle = @fopen
($import_file, 'r');
573 $message = PMA\libraries\Message
::error(
575 'You attempted to load file with unsupported compression (%s). ' .
576 'Either support for it is not implemented or disabled by your ' .
580 $message->addParam($compression);
581 PMA_stopImport($message);
582 // the previous function exits
584 // use isset() because zip compression type does not use a handle
585 if (! $error && isset($import_handle) && $import_handle === false) {
586 $message = PMA\libraries\Message
::error(__('File could not be read!'));
587 PMA_stopImport($message);
589 } elseif (! $error) {
590 if (! isset($import_text) ||
empty($import_text)) {
591 $message = PMA\libraries\Message
::error(
593 'No data was received to import. Either no file name was ' .
594 'submitted, or the file size exceeded the maximum size permitted ' .
595 'by your PHP configuration. See [doc@faq1-16]FAQ 1.16[/doc].'
598 PMA_stopImport($message);
602 // so we can obtain the message
603 //$_SESSION['Import_message'] = $message->getDisplay();
605 // Convert the file's charset if necessary
606 if ($GLOBALS['PMA_recoding_engine'] != PMA_CHARSET_NONE
&& isset($charset_of_file)) {
607 if ($charset_of_file != 'utf-8') {
608 $charset_conversion = true;
610 } elseif (isset($charset_of_file) && $charset_of_file != 'utf-8') {
611 $GLOBALS['dbi']->query('SET NAMES \'' . $charset_of_file . '\'');
612 // We can not show query in this case, it is in different charset
613 $sql_query_disabled = true;
614 $reset_charset = true;
617 // Something to skip? (because timeout has passed)
618 if (! $error && isset($_POST['skip'])) {
619 $original_skip = $skip = intval($_POST['skip']);
620 while ($skip > 0 && ! $finished) {
621 PMA_importGetNextChunk($skip < $read_limit ?
$skip : $read_limit);
622 // Disable read progressivity, otherwise we eat all memory!
624 $skip -= $read_limit;
629 // This array contain the data like numberof valid sql queries in the statement
630 // and complete valid sql statement (which affected for rows)
631 $sql_data = array('valid_sql' => array(), 'valid_queries' => 0);
634 // Check for file existence
635 include_once "libraries/plugin_interface.lib.php";
636 /* @var $import_plugin ImportPlugin */
637 $import_plugin = PMA_getPlugin(
640 'libraries/plugins/import/',
643 if ($import_plugin == null) {
644 $message = PMA\libraries\Message
::error(
645 __('Could not load import plugins, please check your installation!')
647 PMA_stopImport($message);
649 // Do the real import
651 $default_fk_check = PMA\libraries\Util
::handleDisableFKCheckInit();
652 $import_plugin->doImport($sql_data);
653 PMA\libraries\Util
::handleDisableFKCheckCleanup($default_fk_check);
654 } catch (Exception
$e) {
655 PMA\libraries\Util
::handleDisableFKCheckCleanup($default_fk_check);
661 if (! empty($import_handle)) {
662 fclose($import_handle);
665 // Cleanup temporary file
666 if ($file_to_unlink != '') {
667 unlink($file_to_unlink);
670 // Reset charset back, if we did some changes
671 if ($reset_charset) {
672 $GLOBALS['dbi']->query('SET CHARACTER SET utf8');
673 $GLOBALS['dbi']->query(
674 'SET SESSION collation_connection =\'' . $collation_connection . '\''
678 // Show correct message
679 if (! empty($id_bookmark) && $_REQUEST['action_bookmark'] == 2) {
680 $message = PMA\libraries\Message
::success(__('The bookmark has been deleted.'));
681 $display_query = $import_text;
682 $error = false; // unset error marker, it was used just to skip processing
683 } elseif (! empty($id_bookmark) && $_REQUEST['action_bookmark'] == 1) {
684 $message = PMA\libraries\Message
::notice(__('Showing bookmark'));
685 } elseif ($bookmark_created) {
686 $special_message = '[br]' . sprintf(
687 __('Bookmark %s has been created.'),
688 htmlspecialchars($_POST['bkm_label'])
690 } elseif ($finished && ! $error) {
691 // Do not display the query with message, we do it separately
692 $display_query = ';';
693 if ($import_type != 'query') {
694 $message = PMA\libraries\Message
::success(
697 'Import has been successfully finished, %d query executed.',
698 'Import has been successfully finished, %d queries executed.',
703 $message->addParam($executed_queries);
705 if ($import_notice) {
706 $message->addString($import_notice);
708 if (! empty($local_import_file)) {
709 $message->addString('(' . htmlspecialchars($local_import_file) . ')');
712 '(' . htmlspecialchars($_FILES['import_file']['name']) . ')'
718 // Did we hit timeout? Tell it user.
719 if ($timeout_passed) {
720 $importUrl = $err_url .= '&timeout_passed=1&offset=' . urlencode(
723 if (isset($local_import_file)) {
724 $importUrl .= '&local_import_file=' . urlencode($local_import_file);
726 $message = PMA\libraries\Message
::error(
728 'Script timeout passed, if you want to finish import,'
729 . ' please %sresubmit the same file%s and import will resume.'
732 $message->addParam('<a href="' . $importUrl . '">', false);
733 $message->addParam('</a>', false);
735 if ($offset == 0 ||
(isset($original_skip) && $original_skip == $offset)) {
738 'However on last run no data has been parsed,'
739 . ' this usually means phpMyAdmin won\'t be able to'
740 . ' finish this import unless you increase php time limits.'
746 // if there is any message, copy it into $_SESSION as well,
747 // so we can obtain it by AJAX call
748 if (isset($message)) {
749 $_SESSION['Import_message']['message'] = $message->getDisplay();
751 // Parse and analyze the query, for correct db and table name
752 // in case of a query typed in the query window
753 // (but if the query is too large, in case of an imported file, the parser
754 // can choke on it so avoid parsing)
755 $sqlLength = mb_strlen($sql_query);
756 if ($sqlLength <= $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
757 include_once 'libraries/parse_analyze.lib.php';
760 $analyzed_sql_results,
763 ) = PMA_parseAnalyze($sql_query, $db);
764 // @todo: possibly refactor
765 extract($analyzed_sql_results);
767 if ($table != $table_from_sql && !empty($table_from_sql)) {
768 $table = $table_from_sql;
772 // There was an error?
773 if (isset($my_die)) {
774 foreach ($my_die as $key => $die) {
775 PMA\libraries\Util
::mysqlDie(
776 $die['error'], $die['sql'], false, $err_url, $error
783 if (! empty($sql_data) && ($sql_data['valid_queries'] > 1)) {
784 $_SESSION['is_multi_query'] = true;
785 $sql_queries = $sql_data['valid_sql'];
787 $sql_queries = array($sql_query);
792 foreach ($sql_queries as $sql_query) {
795 include_once 'libraries/parse_analyze.lib.php';
797 $analyzed_sql_results,
800 ) = PMA_parseAnalyze($sql_query, $db);
801 // @todo: possibly refactor
802 extract($analyzed_sql_results);
804 // Check if User is allowed to issue a 'DROP DATABASE' Statement
805 if (PMA_hasNoRightsToDropDatabase(
806 $analyzed_sql_results, $cfg['AllowUserDropDatabase'], $GLOBALS['is_superuser']
808 PMA\libraries\Util
::mysqlDie(
809 __('"DROP DATABASE" statements are disabled.'),
812 $_SESSION['Import_message']['go_back_url']
817 if ($table != $table_from_sql && !empty($table_from_sql)) {
818 $table = $table_from_sql;
821 $html_output .= PMA_executeQueryAndGetQueryResponse(
822 $analyzed_sql_results, // analyzed_sql_results
823 false, // is_gotofile
826 null, // find_real_end
827 null, // sql_query_for_bookmark - see below
829 null, // message_to_show
833 $pmaThemeImage, // pmaThemeImage
835 null, // disp_message
837 $sql_query, // sql_query
838 null, // selectedTables
839 null // complete_query
843 // sql_query_for_bookmark is not included in PMA_executeQueryAndGetQueryResponse
844 // since only one bookmark has to be added for all the queries submitted through
846 if (! empty($_POST['bkm_label']) && ! empty($import_text)) {
847 $cfgBookmark = PMA_Bookmark_getParams();
848 PMA_storeTheQueryAsBookmark(
849 $db, $cfgBookmark['user'],
850 $_REQUEST['sql_query'], $_POST['bkm_label'],
851 isset($_POST['bkm_replace']) ?
$_POST['bkm_replace'] : null
855 $response = PMA\libraries\Response
::getInstance();
856 $response->addJSON('ajax_reload', $ajax_reload);
857 $response->addHTML($html_output);
860 } else if ($result) {
861 // Save a Bookmark with more than one queries (if Bookmark label given).
862 if (! empty($_POST['bkm_label']) && ! empty($import_text)) {
863 $cfgBookmark = PMA_Bookmark_getParams();
864 PMA_storeTheQueryAsBookmark(
865 $db, $cfgBookmark['user'],
866 $_REQUEST['sql_query'], $_POST['bkm_label'],
867 isset($_POST['bkm_replace']) ?
$_POST['bkm_replace'] : null
871 $response = PMA\libraries\Response
::getInstance();
872 $response->setRequestStatus(true);
873 $response->addJSON('message', PMA\libraries\Message
::success($msg));
876 PMA\libraries\Util
::getMessage($msg, $sql_query, 'success')
878 } else if ($result == false) {
879 $response = PMA\libraries\Response
::getInstance();
880 $response->setRequestStatus(false);
881 $response->addJSON('message', PMA\libraries\Message
::error($msg));
883 $active_page = $goto;
887 // If there is request for ROLLBACK in the end.
888 if (isset($_REQUEST['rollback_query'])) {
889 $GLOBALS['dbi']->query('ROLLBACK');