2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Main export handling code
10 * Get the variables sent or posted to this script and a core script
12 if (!defined('TESTSUITE')) {
14 * If we are sending the export file (as opposed to just displaying it
15 * as text), we have to bypass the usual PMA_Response mechanism
17 if (isset($_POST['output_format']) && $_POST['output_format'] == 'sendit') {
18 define('PMA_BYPASS_GET_INSTANCE', 1);
20 include_once 'libraries/common.inc.php';
21 include_once 'libraries/zip.lib.php';
22 include_once 'libraries/plugin_interface.lib.php';
24 //check if it's the GET request to check export time out
25 if (isset($_GET['check_time_out'])) {
26 if (isset($_SESSION['pma_export_error'])) {
27 $err = $_SESSION['pma_export_error'];
28 unset($_SESSION['pma_export_error']);
36 * Sets globals from $_POST
38 * - Please keep the parameters in order of their appearance in the form
39 * - Some of these parameters are not used, as the code below directly
40 * verifies from the superglobal $_POST or $_REQUEST
62 'htmlword_structure_or_data',
65 'mediawiki_structure_or_data',
68 'pdf_structure_or_data',
69 'odt_structure_or_data',
75 'codegen_structure_or_data',
81 'excel_structure_or_data',
82 'yaml_structure_or_data',
84 'ods_structure_or_data',
86 'json_structure_or_data',
87 'xml_structure_or_data',
88 'xml_export_functions',
89 'xml_export_procedures',
91 'xml_export_triggers',
93 'xml_export_contents',
94 'texytext_structure_or_data',
97 'phparray_structure_or_data',
98 'sql_include_comments',
103 'sql_use_transaction',
106 'sql_structure_or_data',
107 'sql_create_database',
109 'sql_procedure_function',
110 'sql_create_table_statements',
112 'sql_auto_increment',
119 'sql_max_query_size',
130 'csv_structure_or_data',
131 // csv_replace should have been here but we use it directly from $_POST
133 'latex_structure_or_data',
134 'latex_structure_caption',
135 'latex_structure_continued_caption',
136 'latex_structure_label',
141 'latex_data_caption',
142 'latex_data_continued_caption',
147 foreach ($post_params as $one_post_param) {
148 if (isset($_POST[$one_post_param])) {
149 $GLOBALS[$one_post_param] = $_POST[$one_post_param];
153 // sanitize this parameter which will be used below in a file inclusion
154 $what = PMA_securePath($what);
156 PMA_Util
::checkParameters(array('what', 'export_type'));
158 // export class instance, not array of properties, as before
159 $export_plugin = PMA_getPlugin(
162 'libraries/plugins/export/',
164 'export_type' => $export_type,
165 'single_table' => isset($single_table)
169 // Backward compatbility
173 if (! isset($export_plugin)) {
174 PMA_fatalError(__('Bad type!'));
178 * valid compression methods
180 $compression_methods = array(
186 * init and variable checking
188 $compression = false;
190 $save_on_server = false;
191 $buffer_needed = false;
193 // Is it a quick or custom export?
194 if ($_REQUEST['quick_or_custom'] == 'quick') {
195 $quick_export = true;
197 $quick_export = false;
200 if ($_REQUEST['output_format'] == 'astext') {
204 if (in_array($_REQUEST['compression'], $compression_methods)) {
205 $compression = $_REQUEST['compression'];
206 $buffer_needed = true;
208 if (($quick_export && ! empty($_REQUEST['quick_export_onserver']))
209 ||
(! $quick_export && ! empty($_REQUEST['onserver']))
212 $onserver = $_REQUEST['quick_export_onserver'];
214 $onserver = $_REQUEST['onserver'];
216 // Will we save dump on server?
217 $save_on_server = ! empty($cfg['SaveDir']) && $onserver;
221 // Does export require to be into file?
222 if ($export_plugin->getProperties()->getForceFile() != null && ! $asfile) {
223 $message = PMA_Message
::error(
224 __('Selected export type has to be saved in file!')
226 if ($export_type == 'server') {
227 $active_page = 'server_export.php';
228 include 'server_export.php';
229 } elseif ($export_type == 'database') {
230 $active_page = 'db_export.php';
231 include 'db_export.php';
233 $active_page = 'tbl_export.php';
234 include 'tbl_export.php';
239 // Generate error url and check for needed variables
240 if ($export_type == 'server') {
241 $err_url = 'server_export.php?' . PMA_URL_getCommon();
242 } elseif ($export_type == 'database' && strlen($db)) {
243 $err_url = 'db_export.php?' . PMA_URL_getCommon($db);
244 // Check if we have something to export
245 if (isset($table_select)) {
246 $tables = $table_select;
250 } elseif ($export_type == 'table' && strlen($db) && strlen($table)) {
251 $err_url = 'tbl_export.php?' . PMA_URL_getCommon($db, $table);
253 PMA_fatalError(__('Bad parameters!'));
257 * Increase time limit for script execution and initializes some variables
259 @set_time_limit
($cfg['ExecTimeLimit']);
260 if (! empty($cfg['MemoryLimit'])) {
261 @ini_set
('memory_limit', $cfg['MemoryLimit']);
263 register_shutdown_function('PMA_shutdown');
264 // Start with empty buffer
266 $dump_buffer_len = 0;
268 // We send fake headers to avoid browser timeout when buffering
269 $time_start = time();
273 * Sets a session variable upon a possible fatal error during export
277 function PMA_shutdown()
279 $a = error_get_last();
280 if ($a != null && strpos($a['message'], "execution time")) {
281 //write in partially downloaded file for future reference of user
283 //set session variable to check if there was error while exporting
284 $_SESSION['pma_export_error'] = $a['message'];
288 * Detect ob_gzhandler
292 function PMA_isGzHandlerEnabled()
294 return in_array('ob_gzhandler', ob_list_handlers());
298 * Detect whether gzencode is needed; it might not be needed if
299 * the server is already compressing by itself
301 * @return bool Whether gzencode is needed
303 function PMA_gzencodeNeeded()
306 * We should gzencode only if the function exists
307 * but we don't want to compress twice, therefore
308 * gzencode only if transparent compression is not enabled
309 * and gz compression was not asked via $cfg['OBGzip']
310 * but transparent compression does not apply when saving to server
312 if (@function_exists
('gzencode')
313 && ((! @ini_get
('zlib.output_compression')
314 && ! PMA_isGzHandlerEnabled())
315 ||
$GLOBALS['save_on_server'])
324 * Output handler for all exports, if needed buffering, it stores data into
325 * $dump_buffer, otherwise it prints thems out.
327 * @param string $line the insert statement
329 * @return bool Whether output succeeded
331 function PMA_exportOutputHandler($line)
333 global $time_start, $dump_buffer, $dump_buffer_len, $save_filename;
335 // Kanji encoding convert feature
336 if ($GLOBALS['output_kanji_conversion']) {
337 $line = PMA_Kanji_strConv(
340 isset($GLOBALS['xkana']) ?
$GLOBALS['xkana'] : ''
343 // If we have to buffer data, we will perform everything at once at the end
344 if ($GLOBALS['buffer_needed']) {
346 $dump_buffer .= $line;
347 if ($GLOBALS['onfly_compression']) {
349 $dump_buffer_len +
= strlen($line);
351 if ($dump_buffer_len > $GLOBALS['memory_limit']) {
352 if ($GLOBALS['output_charset_conversion']) {
353 $dump_buffer = PMA_convertString(
355 $GLOBALS['charset_of_file'],
359 if ($GLOBALS['compression'] == 'gzip'
360 && PMA_gzencodeNeeded()
363 // without the optional parameter level because it bugs
364 $dump_buffer = gzencode($dump_buffer);
366 if ($GLOBALS['save_on_server']) {
367 $write_result = @fwrite
($GLOBALS['file_handle'], $dump_buffer);
368 if ($write_result != strlen($dump_buffer)) {
369 $GLOBALS['message'] = PMA_Message
::error(
370 __('Insufficient space to save the file %s.')
372 $GLOBALS['message']->addParam($save_filename);
379 $dump_buffer_len = 0;
383 if ($time_start >= $time_now +
30) {
384 $time_start = $time_now;
385 header('X-pmaPing: Pong');
389 if ($GLOBALS['asfile']) {
390 if ($GLOBALS['output_charset_conversion']) {
391 $line = PMA_convertString(
393 $GLOBALS['charset_of_file'],
397 if ($GLOBALS['save_on_server'] && strlen($line) > 0) {
398 $write_result = @fwrite
($GLOBALS['file_handle'], $line);
399 if (! $write_result ||
($write_result != strlen($line))) {
400 $GLOBALS['message'] = PMA_Message
::error(
401 __('Insufficient space to save the file %s.')
403 $GLOBALS['message']->addParam($save_filename);
407 if ($time_start >= $time_now +
30) {
408 $time_start = $time_now;
409 header('X-pmaPing: Pong');
412 // We export as file - output normally
416 // We export as html - replace special chars
417 echo htmlspecialchars($line);
421 } // end of the 'PMA_exportOutputHandler()' function
423 // Defines the default <CR><LF> format.
424 // For SQL always use \n as MySQL wants this on all platforms.
425 if (!defined('TESTSUITE')) {
426 if ($what == 'sql') {
429 $crlf = PMA_Util
::whichCrlf();
432 $output_kanji_conversion = function_exists('PMA_Kanji_strConv')
435 // Do we need to convert charset?
436 $output_charset_conversion = $asfile
437 && $GLOBALS['PMA_recoding_engine'] != PMA_CHARSET_NONE
438 && isset($charset_of_file) && $charset_of_file != 'utf-8'
441 // Use on the fly compression?
442 $onfly_compression = $GLOBALS['cfg']['CompressOnFly']
443 && $compression == 'gzip';
444 if ($onfly_compression) {
445 $memory_limit = trim(@ini_get
('memory_limit'));
446 $memory_limit_num = (int)substr($memory_limit, 0, -1);
448 if (empty($memory_limit) ||
'-1' == $memory_limit) {
449 $memory_limit = 2 * 1024 * 1024;
450 } elseif (strtolower(substr($memory_limit, -1)) == 'm') {
451 $memory_limit = $memory_limit_num * 1024 * 1024;
452 } elseif (strtolower(substr($memory_limit, -1)) == 'k') {
453 $memory_limit = $memory_limit_num * 1024;
454 } elseif (strtolower(substr($memory_limit, -1)) == 'g') {
455 $memory_limit = $memory_limit_num * 1024 * 1024 * 1024;
457 $memory_limit = (int)$memory_limit;
460 // Some of memory is needed for other things and as threshold.
461 // During export I had allocated (see memory_get_usage function)
462 // approx 1.2MB so this comes from that.
463 if ($memory_limit > 1500000) {
464 $memory_limit -= 1500000;
467 // Some memory is needed for compression, assume 1/3
471 // Generate filename and mime type if needed
473 $pma_uri_parts = parse_url($cfg['PmaAbsoluteUri']);
474 if ($export_type == 'server') {
475 if (isset($remember_template)) {
476 $GLOBALS['PMA_Config']->setUserValue(
477 'pma_server_filename_template',
478 'Export/file_template_server',
482 } elseif ($export_type == 'database') {
483 if (isset($remember_template)) {
484 $GLOBALS['PMA_Config']->setUserValue(
485 'pma_db_filename_template',
486 'Export/file_template_database',
491 if (isset($remember_template)) {
492 $GLOBALS['PMA_Config']->setUserValue(
493 'pma_table_filename_template',
494 'Export/file_template_table',
499 $filename = PMA_Util
::expandUserString($filename_template);
500 // remove dots in filename (coming from either the template or already
501 // part of the filename) to avoid a remote code execution vulnerability
502 $filename = PMA_sanitizeFilename($filename, $replaceDots = true);
504 // Grab basic dump extension and mime type
505 // Check if the user already added extension;
506 // get the substring where the extension would be if it was included
507 $extension_start_pos = strlen($filename) - strlen(
508 $export_plugin->getProperties()->getExtension()
510 $user_extension = substr($filename, $extension_start_pos, strlen($filename));
511 $required_extension = "." . $export_plugin->getProperties()->getExtension();
512 if (strtolower($user_extension) != $required_extension) {
513 $filename .= $required_extension;
515 $mime_type = $export_plugin->getProperties()->getMimeType();
517 // If dump is going to be compressed, set correct mime_type and add
518 // compression to extension
519 if ($compression == 'gzip') {
521 $mime_type = 'application/x-gzip';
522 } elseif ($compression == 'zip') {
524 $mime_type = 'application/zip';
528 // Open file on server if needed
529 if ($save_on_server) {
530 $save_filename = PMA_Util
::userDir($cfg['SaveDir'])
531 . preg_replace('@[/\\\\]@', '_', $filename);
533 if (file_exists($save_filename)
534 && ((! $quick_export && empty($_REQUEST['onserverover']))
536 && $_REQUEST['quick_export_onserverover'] != 'saveitover'))
538 $message = PMA_Message
::error(
540 'File %s already exists on server, '
541 . 'change filename or check overwrite option.'
544 $message->addParam($save_filename);
546 if (is_file($save_filename) && ! is_writable($save_filename)) {
547 $message = PMA_Message
::error(
549 'The web server does not have permission '
550 . 'to save the file %s.'
553 $message->addParam($save_filename);
555 if (! $file_handle = @fopen
($save_filename, 'w')) {
556 $message = PMA_Message
::error(
558 'The web server does not have permission '
559 . 'to save the file %s.'
562 $message->addParam($save_filename);
566 if (isset($message)) {
567 if ($export_type == 'server') {
568 $active_page = 'server_export.php';
569 include 'server_export.php';
570 } elseif ($export_type == 'database') {
571 $active_page = 'db_export.php';
572 include 'db_export.php';
574 $active_page = 'tbl_export.php';
575 include 'tbl_export.php';
582 * Send headers depending on whether the user chose to download a dump file
585 if (! $save_on_server) {
588 // (avoid rewriting data containing HTML with anchors and forms;
589 // this was reported to happen under Plesk)
590 @ini_set
('url_rewriter.tags', '');
591 $filename = PMA_sanitizeFilename($filename);
593 PMA_downloadHeader($filename, $mime_type);
596 if ($export_type == 'database') {
597 $num_tables = count($tables);
598 if ($num_tables == 0) {
599 $message = PMA_Message
::error(
600 __('No tables found in database.')
602 $active_page = 'db_export.php';
603 include 'db_export.php';
607 $backup_cfgServer = $cfg['Server'];
608 $cfg['Server'] = $backup_cfgServer;
609 unset($backup_cfgServer);
610 echo "\n" . '<div style="text-align: ' . $cell_align_left . '">' . "\n";
611 //echo ' <pre>' . "\n";
614 * Displays a back button with all the $_REQUEST data in the URL
615 * (store in a variable to also display after the textarea)
617 $back_button = '<p>[ <a href="';
618 if ($export_type == 'server') {
619 $back_button .= 'server_export.php?' . PMA_URL_getCommon();
620 } elseif ($export_type == 'database') {
621 $back_button .= 'db_export.php?' . PMA_URL_getCommon($db);
623 $back_button .= 'tbl_export.php?' . PMA_URL_getCommon($db, $table);
626 // Convert the multiple select elements from an array to a string
627 if ($export_type == 'server' && isset($_REQUEST['db_select'])) {
628 $_REQUEST['db_select'] = implode(",", $_REQUEST['db_select']);
629 } elseif ($export_type == 'database'
630 && isset($_REQUEST['table_select'])
632 $_REQUEST['table_select'] = implode(",", $_REQUEST['table_select']);
635 foreach ($_REQUEST as $name => $value) {
636 $back_button .= '&' . urlencode($name) . '=' . urlencode($value);
638 $back_button .= '&repopulate=1">Back</a> ]</p>';
641 echo '<form name="nofunction">' . "\n";
642 echo '<textarea name="sqldump" cols="50" rows="30" '
643 . 'id="textSQLDUMP" wrap="OFF">' . "\n";
647 // Fake loop just to allow skip of remain of this code by break, I'd really
648 // need exceptions here :-)
651 // Add possibly some comments to export
652 if (! $export_plugin->exportHeader($db)) {
656 // Will we need relation & co. setup?
657 $do_relation = isset($GLOBALS[$what . '_relation']);
658 $do_comments = isset($GLOBALS[$what . '_include_comments'])
659 ||
isset($GLOBALS[$what . '_comments']) ;
660 $do_mime = isset($GLOBALS[$what . '_mime']);
661 if ($do_relation ||
$do_comments ||
$do_mime) {
662 $cfgRelation = PMA_getRelationsParam();
665 include_once 'libraries/transformations.lib.php';
668 // Include dates in export?
669 $do_dates = isset($GLOBALS[$what . '_dates']);
671 $whatStrucOrData = $GLOBALS[$what . '_structure_or_data'];
676 // Gets the number of tables if a dump of a database has been required
677 if ($export_type == 'server') {
678 if (isset($db_select)) {
679 $tmp_select = implode($db_select, '|');
680 $tmp_select = '|' . $tmp_select . '|';
682 // Walk over databases
683 foreach ($GLOBALS['pma']->databases
as $current_db) {
684 if (isset($tmp_select)
685 && strpos(' ' . $tmp_select, '|' . $current_db . '|')
687 if (! $export_plugin->exportDBHeader($current_db)) {
690 if (! $export_plugin->exportDBCreate($current_db)) {
693 if (method_exists($export_plugin, 'exportRoutines')
694 && strpos($whatStrucOrData, 'structure') !== false
695 && isset($GLOBALS['sql_procedure_function'])
697 $export_plugin->exportRoutines($current_db);
700 $tables = $GLOBALS['dbi']->getTables($current_db);
702 foreach ($tables as $table) {
703 // if this is a view, collect it for later;
704 // views must be exported after the tables
705 $is_view = PMA_Table
::isView($current_db, $table);
709 if ($whatStrucOrData == 'structure'
710 ||
$whatStrucOrData == 'structure_and_data'
712 // for a view, export a stand-in definition of the table
713 // to resolve view dependencies
714 if (! $export_plugin->exportStructure(
715 $current_db, $table, $crlf, $err_url,
716 $is_view ?
'stand_in' : 'create_table', $export_type,
717 $do_relation, $do_comments, $do_mime, $do_dates
722 // if this is a view or a merge table, don't export data
723 if (($whatStrucOrData == 'data'
724 ||
$whatStrucOrData == 'structure_and_data')
725 && ! ($is_view || PMA_Table
::isMerge($current_db, $table))
727 $local_query = 'SELECT * FROM '
728 . PMA_Util
::backquote($current_db)
729 . '.' . PMA_Util
::backquote($table);
730 if (! $export_plugin->exportData(
731 $current_db, $table, $crlf, $err_url, $local_query
736 // now export the triggers (needs to be done after the data
737 // because triggers can modify already imported tables)
738 if ($whatStrucOrData == 'structure'
739 ||
$whatStrucOrData == 'structure_and_data'
741 if (! $export_plugin->exportStructure(
742 $current_db, $table, $crlf, $err_url,
743 'triggers', $export_type,
744 $do_relation, $do_comments, $do_mime, $do_dates
750 foreach ($views as $view) {
751 // no data export for a view
752 if ($whatStrucOrData == 'structure'
753 ||
$whatStrucOrData == 'structure_and_data'
755 if (! $export_plugin->exportStructure(
756 $current_db, $view, $crlf, $err_url,
757 'create_view', $export_type,
758 $do_relation, $do_comments, $do_mime, $do_dates
764 if (! $export_plugin->exportDBFooter($current_db)) {
769 } elseif ($export_type == 'database') {
770 if (! $export_plugin->exportDBHeader($db)) {
773 if (! $export_plugin->exportDBCreate($db)) {
777 if (method_exists($export_plugin, 'exportRoutines')
778 && strpos($GLOBALS['sql_structure_or_data'], 'structure') !== false
779 && isset($GLOBALS['sql_procedure_function'])
781 $export_plugin->exportRoutines($db);
787 // $tables contains the choices from the user (via $table_select)
788 foreach ($tables as $table) {
789 // if this is a view, collect it for later;
790 // views must be exported after the tables
791 $is_view = PMA_Table
::isView($db, $table);
795 if ($whatStrucOrData == 'structure'
796 ||
$whatStrucOrData == 'structure_and_data'
798 // for a view, export a stand-in definition of the table
799 // to resolve view dependencies
800 if (! $export_plugin->exportStructure(
801 $db, $table, $crlf, $err_url,
802 $is_view ?
'stand_in' : 'create_table', $export_type,
803 $do_relation, $do_comments, $do_mime, $do_dates
808 // if this is a view or a merge table, don't export data
809 if (($whatStrucOrData == 'data'
810 ||
$whatStrucOrData == 'structure_and_data')
811 && ! ($is_view || PMA_Table
::isMerge($db, $table))
813 $local_query = 'SELECT * FROM ' . PMA_Util
::backquote($db)
814 . '.' . PMA_Util
::backquote($table);
815 if (! $export_plugin->exportData(
816 $db, $table, $crlf, $err_url, $local_query
821 // now export the triggers (needs to be done after the data because
822 // triggers can modify already imported tables)
823 if ($whatStrucOrData == 'structure'
824 ||
$whatStrucOrData == 'structure_and_data'
826 if (! $export_plugin->exportStructure(
827 $db, $table, $crlf, $err_url,
828 'triggers', $export_type,
829 $do_relation, $do_comments, $do_mime, $do_dates
835 foreach ($views as $view) {
836 // no data export for a view
837 if ($whatStrucOrData == 'structure'
838 ||
$whatStrucOrData == 'structure_and_data'
840 if (! $export_plugin->exportStructure(
841 $db, $view, $crlf, $err_url,
842 'create_view', $export_type,
843 $do_relation, $do_comments, $do_mime, $do_dates
850 if (! $export_plugin->exportDBFooter($db)) {
854 if (! $export_plugin->exportDBHeader($db)) {
857 // We export just one table
858 // $allrows comes from the form when "Dump all rows" has been selected
864 $add_query = ' LIMIT '
865 . (($limit_from > 0) ?
$limit_from . ', ' : '')
871 $is_view = PMA_Table
::isView($db, $table);
872 if ($whatStrucOrData == 'structure'
873 ||
$whatStrucOrData == 'structure_and_data'
875 if (! $export_plugin->exportStructure(
876 $db, $table, $crlf, $err_url,
877 $is_view ?
'create_view' : 'create_table', $export_type,
878 $do_relation, $do_comments, $do_mime, $do_dates
883 // If this is an export of a single view, we have to export data;
884 // for example, a PDF report
885 // if it is a merge table, no data is exported
886 if (($whatStrucOrData == 'data'
887 ||
$whatStrucOrData == 'structure_and_data')
888 && ! PMA_Table
::isMerge($db, $table)
890 if (! empty($sql_query)) {
891 // only preg_replace if needed
892 if (! empty($add_query)) {
893 // remove trailing semicolon before adding a LIMIT
894 $sql_query = preg_replace('%;\s*$%', '', $sql_query);
896 $local_query = $sql_query . $add_query;
897 $GLOBALS['dbi']->selectDb($db);
899 $local_query = 'SELECT * FROM ' . PMA_Util
::backquote($db)
900 . '.' . PMA_Util
::backquote($table) . $add_query;
902 if (! $export_plugin->exportData(
903 $db, $table, $crlf, $err_url, $local_query
908 // now export the triggers (needs to be done after the data because
909 // triggers can modify already imported tables)
910 if ($whatStrucOrData == 'structure'
911 ||
$whatStrucOrData == 'structure_and_data'
913 if (! $export_plugin->exportStructure(
914 $db, $table, $crlf, $err_url,
915 'triggers', $export_type,
916 $do_relation, $do_comments, $do_mime, $do_dates
921 if (! $export_plugin->exportDBFooter($db)) {
925 if (! $export_plugin->exportFooter()) {
932 if ($save_on_server && isset($message)) {
933 if ($export_type == 'server') {
934 $active_page = 'server_export.php';
935 include 'server_export.php';
936 } elseif ($export_type == 'database') {
937 $active_page = 'db_export.php';
938 include 'db_export.php';
940 $active_page = 'tbl_export.php';
941 include 'tbl_export.php';
947 * Send the dump as a file...
949 if (! empty($asfile)) {
950 // Convert the charset if required.
951 if ($output_charset_conversion) {
952 $dump_buffer = PMA_convertString(
954 $GLOBALS['charset_of_file'],
959 // Do the compression
960 // 1. as a zipped file
961 if ($compression == 'zip') {
962 if (@function_exists
('gzcompress')) {
963 $zipfile = new ZipFile();
964 $zipfile->addFile($dump_buffer, substr($filename, 0, -4));
965 $dump_buffer = $zipfile->file();
967 } elseif ($compression == 'gzip' && PMA_gzencodeNeeded()) {
968 // 3. as a gzipped file
969 // without the optional parameter level because it bugs
970 $dump_buffer = gzencode($dump_buffer);
973 /* If we saved on server, we have to close file now */
974 if ($save_on_server) {
975 $write_result = @fwrite
($file_handle, $dump_buffer);
976 fclose($file_handle);
977 if (strlen($dump_buffer) > 0
978 && (! $write_result ||
($write_result != strlen($dump_buffer)))
980 $message = new PMA_Message(
981 __('Insufficient space to save the file %s.'),
986 $message = new PMA_Message(
987 __('Dump has been saved to file %s.'),
988 PMA_Message
::SUCCESS
,
993 if ($export_type == 'server') {
994 $active_page = 'server_export.php';
995 include_once 'server_export.php';
996 } elseif ($export_type == 'database') {
997 $active_page = 'db_export.php';
998 include_once 'db_export.php';
1000 $active_page = 'tbl_export.php';
1001 include_once 'tbl_export.php';
1009 * Displays the dump...
1011 * Close the html tags and add the footers if dump is displayed on screen
1013 echo '</textarea>' . "\n"
1014 . ' </form>' . "\n";
1018 echo '</div>' . "\n";
1021 <script type
="text/javascript">
1023 var $body = $
("body");
1025 .width($body.width() - 50)
1026 .height($body.height() - 100);