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 require_once 'libraries/common.inc.php';
13 require_once 'libraries/zip.lib.php';
14 require_once 'libraries/plugin_interface.lib.php';
17 * Sets globals from $_POST
19 * - Please keep the parameters in order of their appearance in the form
20 * - Some of these parameters are not used, as the code below directly
21 * verifies from the superglobal $_POST or $_REQUEST
40 'htmlword_structure_or_data',
43 'mediawiki_structure_or_data',
46 'pdf_structure_or_data',
47 'odt_structure_or_data',
53 'codegen_structure_or_data',
58 'excel_structure_or_data',
59 'yaml_structure_or_data',
61 'ods_structure_or_data',
63 'json_structure_or_data',
64 'xml_structure_or_data',
65 'xml_export_functions',
66 'xml_export_procedures',
68 'xml_export_triggers',
70 'xml_export_contents',
71 'texytext_structure_or_data',
74 'phparray_structure_or_data',
75 'sql_include_comments',
80 'sql_use_transaction',
83 'sql_structure_or_data',
85 'sql_procedure_function',
86 'sql_create_table_statements',
104 'csv_structure_or_data',
106 'latex_structure_or_data',
107 'latex_structure_caption',
108 'latex_structure_continued_caption',
109 'latex_structure_label',
114 'latex_data_caption',
115 'latex_data_continued_caption',
120 foreach ($post_params as $one_post_param) {
121 if (isset($_POST[$one_post_param])) {
122 $GLOBALS[$one_post_param] = $_POST[$one_post_param];
126 // sanitize this parameter which will be used below in a file inclusion
127 $what = PMA_securePath($what);
129 PMA_Util
::checkParameters(array('what', 'export_type'));
131 // export class instance, not array of properties, as before
132 $export_plugin = PMA_getPlugin(
135 'libraries/plugins/export/',
137 'export_type' => $export_type,
138 'single_table' => isset($single_table)
142 // Backward compatbility
146 if (! isset($export_plugin)) {
147 PMA_fatalError(__('Bad type!'));
151 * valid compression methods
153 $compression_methods = array(
160 * init and variable checking
162 $compression = false;
164 $save_on_server = false;
165 $buffer_needed = false;
167 // Is it a quick or custom export?
168 if ($_REQUEST['quick_or_custom'] == 'quick') {
169 $quick_export = true;
171 $quick_export = false;
174 if ($_REQUEST['output_format'] == 'astext') {
178 if (in_array($_REQUEST['compression'], $compression_methods)) {
179 $compression = $_REQUEST['compression'];
180 $buffer_needed = true;
182 if (($quick_export && ! empty($_REQUEST['quick_export_onserver']))
183 ||
(! $quick_export && ! empty($_REQUEST['onserver']))
186 $onserver = $_REQUEST['quick_export_onserver'];
188 $onserver = $_REQUEST['onserver'];
190 // Will we save dump on server?
191 $save_on_server = ! empty($cfg['SaveDir']) && $onserver;
195 // Does export require to be into file?
196 if ($export_plugin->getProperties()->getForceFile() != null && ! $asfile) {
197 $message = PMA_Message
::error(
198 __('Selected export type has to be saved in file!')
200 if ($export_type == 'server') {
201 $active_page = 'server_export.php';
202 include 'server_export.php';
203 } elseif ($export_type == 'database') {
204 $active_page = 'db_export.php';
205 include 'db_export.php';
207 $active_page = 'tbl_export.php';
208 include 'tbl_export.php';
213 // Generate error url and check for needed variables
214 if ($export_type == 'server') {
215 $err_url = 'server_export.php?' . PMA_generate_common_url();
216 } elseif ($export_type == 'database' && strlen($db)) {
217 $err_url = 'db_export.php?' . PMA_generate_common_url($db);
218 // Check if we have something to export
219 if (isset($table_select)) {
220 $tables = $table_select;
224 } elseif ($export_type == 'table' && strlen($db) && strlen($table)) {
225 $err_url = 'tbl_export.php?' . PMA_generate_common_url($db, $table);
227 PMA_fatalError(__('Bad parameters!'));
231 * Increase time limit for script execution and initializes some variables
233 @set_time_limit
($cfg['ExecTimeLimit']);
234 if (! empty($cfg['MemoryLimit'])) {
235 @ini_set
('memory_limit', $cfg['MemoryLimit']);
238 // Start with empty buffer
240 $dump_buffer_len = 0;
242 // We send fake headers to avoid browser timeout when buffering
243 $time_start = time();
247 * Detect ob_gzhandler
251 function PMA_isGzHandlerEnabled()
253 return in_array('ob_gzhandler', ob_list_handlers());
257 * Detect whether gzencode is needed; it might not be needed if
258 * the server is already compressing by itself
260 * @return bool Whether gzencode is needed
262 function PMA_gzencodeNeeded()
264 if (@function_exists
('gzencode')
265 && ! @ini_get
('zlib.output_compression')
266 // Here, we detect Apache's mod_deflate so we bet that
267 // this module is active for this instance of phpMyAdmin
268 // and therefore, will gzip encode the content
269 && ! (function_exists('apache_get_modules')
270 && in_array('mod_deflate', apache_get_modules()))
271 && ! PMA_isGzHandlerEnabled()
280 * Output handler for all exports, if needed buffering, it stores data into
281 * $dump_buffer, otherwise it prints thems out.
283 * @param string $line the insert statement
285 * @return bool Whether output succeeded
287 function PMA_exportOutputHandler($line)
289 global $time_start, $dump_buffer, $dump_buffer_len, $save_filename;
291 // Kanji encoding convert feature
292 if ($GLOBALS['output_kanji_conversion']) {
293 $line = PMA_kanji_str_conv(
296 isset($GLOBALS['xkana']) ?
$GLOBALS['xkana'] : ''
299 // If we have to buffer data, we will perform everything at once at the end
300 if ($GLOBALS['buffer_needed']) {
302 $dump_buffer .= $line;
303 if ($GLOBALS['onfly_compression']) {
305 $dump_buffer_len +
= strlen($line);
307 if ($dump_buffer_len > $GLOBALS['memory_limit']) {
308 if ($GLOBALS['output_charset_conversion']) {
309 $dump_buffer = PMA_convert_string(
311 $GLOBALS['charset_of_file'],
316 if ($GLOBALS['compression'] == 'bzip2'
317 && @function_exists
('bzcompress')
319 $dump_buffer = bzcompress($dump_buffer);
320 } elseif ($GLOBALS['compression'] == 'gzip'
321 && PMA_gzencodeNeeded()
324 // without the optional parameter level because it bugs
325 $dump_buffer = gzencode($dump_buffer);
327 if ($GLOBALS['save_on_server']) {
328 $write_result = @fwrite
($GLOBALS['file_handle'], $dump_buffer);
329 if (! $write_result ||
($write_result != strlen($dump_buffer))) {
330 $GLOBALS['message'] = PMA_Message
::error(
331 __('Insufficient space to save the file %s.')
333 $GLOBALS['message']->addParam($save_filename);
340 $dump_buffer_len = 0;
344 if ($time_start >= $time_now +
30) {
345 $time_start = $time_now;
346 header('X-pmaPing: Pong');
350 if ($GLOBALS['asfile']) {
351 if ($GLOBALS['output_charset_conversion']) {
352 $line = PMA_convert_string(
354 $GLOBALS['charset_of_file'],
358 if ($GLOBALS['save_on_server'] && strlen($line) > 0) {
359 $write_result = @fwrite
($GLOBALS['file_handle'], $line);
360 if (! $write_result ||
($write_result != strlen($line))) {
361 $GLOBALS['message'] = PMA_Message
::error(
362 __('Insufficient space to save the file %s.')
364 $GLOBALS['message']->addParam($save_filename);
368 if ($time_start >= $time_now +
30) {
369 $time_start = $time_now;
370 header('X-pmaPing: Pong');
373 // We export as file - output normally
377 // We export as html - replace special chars
378 echo htmlspecialchars($line);
382 } // end of the 'PMA_exportOutputHandler()' function
384 // Defines the default <CR><LF> format.
385 // For SQL always use \n as MySQL wants this on all platforms.
386 if ($what == 'sql') {
389 $crlf = PMA_Util
::whichCrlf();
392 $output_kanji_conversion = function_exists('PMA_kanji_str_conv') && $type != 'xls';
394 // Do we need to convert charset?
395 $output_charset_conversion = $asfile
396 && $GLOBALS['PMA_recoding_engine'] != PMA_CHARSET_NONE
397 && isset($charset_of_file) && $charset_of_file != 'utf-8'
400 // Use on the fly compression?
401 $onfly_compression = $GLOBALS['cfg']['CompressOnFly']
402 && ($compression == 'gzip' ||
$compression == 'bzip2');
403 if ($onfly_compression) {
404 $memory_limit = trim(@ini_get
('memory_limit'));
406 if (empty($memory_limit)) {
407 $memory_limit = 2 * 1024 * 1024;
410 if (strtolower(substr($memory_limit, -1)) == 'm') {
411 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024;
412 } elseif (strtolower(substr($memory_limit, -1)) == 'k') {
413 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024;
414 } elseif (strtolower(substr($memory_limit, -1)) == 'g') {
415 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024 * 1024;
417 $memory_limit = (int)$memory_limit;
420 // Some of memory is needed for other thins and as treshold.
421 // Nijel: During export I had allocated (see memory_get_usage function)
422 // approx 1.2MB so this comes from that.
423 if ($memory_limit > 1500000) {
424 $memory_limit -= 1500000;
427 // Some memory is needed for compression, assume 1/3
431 // Generate filename and mime type if needed
433 $pma_uri_parts = parse_url($cfg['PmaAbsoluteUri']);
434 if ($export_type == 'server') {
435 if (isset($remember_template)) {
436 $GLOBALS['PMA_Config']->setUserValue(
437 'pma_server_filename_template',
438 'Export/file_template_server',
442 } elseif ($export_type == 'database') {
443 if (isset($remember_template)) {
444 $GLOBALS['PMA_Config']->setUserValue(
445 'pma_db_filename_template',
446 'Export/file_template_database',
451 if (isset($remember_template)) {
452 $GLOBALS['PMA_Config']->setUserValue(
453 'pma_table_filename_template',
454 'Export/file_template_table',
459 $filename = PMA_Util
::expandUserString($filename_template);
460 // remove dots in filename (coming from either the template or already
461 // part of the filename) to avoid a remote code execution vulnerability
462 $filename = PMA_sanitizeFilename($filename, $replaceDots = true);
464 // Grab basic dump extension and mime type
465 // Check if the user already added extension;
466 // get the substring where the extension would be if it was included
467 $extension_start_pos = strlen($filename) - strlen(
468 $export_plugin->getProperties()->getExtension()
470 $user_extension = substr($filename, $extension_start_pos, strlen($filename));
471 $required_extension = "." . $export_plugin->getProperties()->getExtension();
472 if (strtolower($user_extension) != $required_extension) {
473 $filename .= $required_extension;
475 $mime_type = $export_plugin->getProperties()->getMimeType();
477 // If dump is going to be compressed, set correct mime_type and add
478 // compression to extension
479 if ($compression == 'bzip2') {
481 $mime_type = 'application/x-bzip2';
482 } elseif ($compression == 'gzip') {
484 $mime_type = 'application/x-gzip';
485 } elseif ($compression == 'zip') {
487 $mime_type = 'application/zip';
491 // Open file on server if needed
492 if ($save_on_server) {
493 $save_filename = PMA_Util
::userDir($cfg['SaveDir'])
494 . preg_replace('@[/\\\\]@', '_', $filename);
496 if (file_exists($save_filename)
497 && ((! $quick_export && empty($onserverover))
499 && $_REQUEST['quick_export_onserverover'] != 'saveitover'))
501 $message = PMA_Message
::error(
502 __('File %s already exists on server, change filename or check overwrite option.')
504 $message->addParam($save_filename);
506 if (is_file($save_filename) && ! is_writable($save_filename)) {
507 $message = PMA_Message
::error(
508 __('The web server does not have permission to save the file %s.')
510 $message->addParam($save_filename);
512 if (! $file_handle = @fopen
($save_filename, 'w')) {
513 $message = PMA_Message
::error(
514 __('The web server does not have permission to save the file %s.')
516 $message->addParam($save_filename);
520 if (isset($message)) {
521 if ($export_type == 'server') {
522 $active_page = 'server_export.php';
523 include 'server_export.php';
524 } elseif ($export_type == 'database') {
525 $active_page = 'db_export.php';
526 include 'db_export.php';
528 $active_page = 'tbl_export.php';
529 include 'tbl_export.php';
536 * Send headers depending on whether the user chose to download a dump file
539 if (! $save_on_server) {
542 // (avoid rewriting data containing HTML with anchors and forms;
543 // this was reported to happen under Plesk)
544 @ini_set
('url_rewriter.tags', '');
545 $filename = PMA_sanitizeFilename($filename);
547 PMA_downloadHeader($filename, $mime_type);
550 if ($export_type == 'database') {
551 $num_tables = count($tables);
552 if ($num_tables == 0) {
553 $message = PMA_Message
::error(__('No tables found in database.'));
554 $active_page = 'db_export.php';
555 include 'db_export.php';
559 $backup_cfgServer = $cfg['Server'];
560 $cfg['Server'] = $backup_cfgServer;
561 unset($backup_cfgServer);
562 echo "\n" . '<div style="text-align: ' . $cell_align_left . '">' . "\n";
563 //echo ' <pre>' . "\n";
566 * Displays a back button with all the $_REQUEST data in the URL
567 * (store in a variable to also display after the textarea)
569 $back_button = '<p>[ <a href="';
570 if ($export_type == 'server') {
571 $back_button .= 'server_export.php?' . PMA_generate_common_url();
572 } elseif ($export_type == 'database') {
573 $back_button .= 'db_export.php?' . PMA_generate_common_url($db);
575 $back_button .= 'tbl_export.php?' . PMA_generate_common_url($db, $table);
578 // Convert the multiple select elements from an array to a string
579 if ($export_type == 'server' && isset($_REQUEST['db_select'])) {
580 $_REQUEST['db_select'] = implode(",", $_REQUEST['db_select']);
581 } elseif ($export_type == 'database' && isset($_REQUEST['table_select'])) {
582 $_REQUEST['table_select'] = implode(",", $_REQUEST['table_select']);
585 foreach ($_REQUEST as $name => $value) {
586 $back_button .= '&' . urlencode($name) . '=' . urlencode($value);
588 $back_button .= '&repopulate=1">Back</a> ]</p>';
591 echo ' <form name="nofunction">' . "\n"
592 // remove auto-select for now: there is no way to select
593 // only a part of the text; anyway, it should obey
594 // $cfg['TextareaAutoSelect']
595 //. ' <textarea name="sqldump" cols="50" rows="30" onclick="this.select();" id="textSQLDUMP" wrap="OFF">' . "\n";
596 . ' <textarea name="sqldump" cols="50" rows="30" id="textSQLDUMP" wrap="OFF">' . "\n";
600 // Fake loop just to allow skip of remain of this code by break, I'd really
601 // need exceptions here :-)
604 // Add possibly some comments to export
605 if (! $export_plugin->exportHeader($db)) {
609 // Will we need relation & co. setup?
610 $do_relation = isset($GLOBALS[$what . '_relation']);
611 $do_comments = isset($GLOBALS[$what . '_include_comments']);
612 $do_mime = isset($GLOBALS[$what . '_mime']);
613 if ($do_relation ||
$do_comments ||
$do_mime) {
614 $cfgRelation = PMA_getRelationsParam();
617 include_once 'libraries/transformations.lib.php';
620 // Include dates in export?
621 $do_dates = isset($GLOBALS[$what . '_dates']);
626 // Gets the number of tables if a dump of a database has been required
627 if ($export_type == 'server') {
628 if (isset($db_select)) {
629 $tmp_select = implode($db_select, '|');
630 $tmp_select = '|' . $tmp_select . '|';
632 // Walk over databases
633 foreach ($GLOBALS['pma']->databases
as $current_db) {
634 if ((isset($tmp_select)
635 && strpos(' ' . $tmp_select, '|' . $current_db . '|'))
636 ||
! isset($tmp_select)
638 if (! $export_plugin->exportDBHeader($current_db)) {
641 if (! $export_plugin->exportDBCreate($current_db)) {
644 if (method_exists($export_plugin, 'exportRoutines')
645 && strpos($GLOBALS['sql_structure_or_data'], 'structure') !== false
646 && isset($GLOBALS['sql_procedure_function'])
648 $export_plugin->exportRoutines($current_db);
651 $tables = PMA_DBI_get_tables($current_db);
653 foreach ($tables as $table) {
654 // if this is a view, collect it for later;
655 // views must be exported after the tables
656 $is_view = PMA_Table
::isView($current_db, $table);
660 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
661 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
663 // for a view, export a stand-in definition of the table
664 // to resolve view dependencies
665 if (! $export_plugin->exportStructure(
666 $current_db, $table, $crlf, $err_url,
667 $is_view ?
'stand_in' : 'create_table', $export_type,
668 $do_relation, $do_comments, $do_mime, $do_dates
673 // if this is a view or a merge table, don't export data
674 if (($GLOBALS[$what . '_structure_or_data'] == 'data'
675 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data')
676 && ! ($is_view || PMA_Table
::isMerge($current_db, $table))
678 $local_query = 'SELECT * FROM ' . PMA_Util
::backquote($current_db)
679 . '.' . PMA_Util
::backquote($table);
680 if (! $export_plugin->exportData($current_db, $table, $crlf, $err_url, $local_query)) {
684 // now export the triggers (needs to be done after the data
685 // because triggers can modify already imported tables)
686 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
687 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
689 if (! $export_plugin->exportStructure(
690 $current_db, $table, $crlf, $err_url,
691 'triggers', $export_type,
692 $do_relation, $do_comments, $do_mime, $do_dates
698 foreach ($views as $view) {
699 // no data export for a view
700 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
701 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
703 if (! $export_plugin->exportStructure(
704 $current_db, $view, $crlf, $err_url,
705 'create_view', $export_type,
706 $do_relation, $do_comments, $do_mime, $do_dates
712 if (! $export_plugin->exportDBFooter($current_db)) {
717 } elseif ($export_type == 'database') {
718 if (! $export_plugin->exportDBHeader($db)) {
722 if (method_exists($export_plugin, 'exportRoutines')
723 && strpos($GLOBALS['sql_structure_or_data'], 'structure') !== false
724 && isset($GLOBALS['sql_procedure_function'])
726 $export_plugin->exportRoutines($db);
731 // $tables contains the choices from the user (via $table_select)
732 foreach ($tables as $table) {
733 // if this is a view, collect it for later; views must be exported after
735 $is_view = PMA_Table
::isView($db, $table);
739 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
740 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
742 // for a view, export a stand-in definition of the table
743 // to resolve view dependencies
744 if (! $export_plugin->exportStructure(
745 $db, $table, $crlf, $err_url,
746 $is_view ?
'stand_in' : 'create_table', $export_type,
747 $do_relation, $do_comments, $do_mime, $do_dates
752 // if this is a view or a merge table, don't export data
753 if (($GLOBALS[$what . '_structure_or_data'] == 'data'
754 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data')
755 && ! ($is_view || PMA_Table
::isMerge($db, $table))
757 $local_query = 'SELECT * FROM ' . PMA_Util
::backquote($db)
758 . '.' . PMA_Util
::backquote($table);
759 if (! $export_plugin->exportData($db, $table, $crlf, $err_url, $local_query)) {
763 // now export the triggers (needs to be done after the data because
764 // triggers can modify already imported tables)
765 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
766 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
768 if (! $export_plugin->exportStructure(
769 $db, $table, $crlf, $err_url,
770 'triggers', $export_type,
771 $do_relation, $do_comments, $do_mime, $do_dates
777 foreach ($views as $view) {
778 // no data export for a view
779 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
780 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
782 if (! $export_plugin->exportStructure(
783 $db, $view, $crlf, $err_url,
784 'create_view', $export_type,
785 $do_relation, $do_comments, $do_mime, $do_dates
792 if (! $export_plugin->exportDBFooter($db)) {
796 if (! $export_plugin->exportDBHeader($db)) {
799 // We export just one table
800 // $allrows comes from the form when "Dump all rows" has been selected
801 if (isset($allrows) && $allrows == '0' && $limit_to > 0 && $limit_from >= 0) {
802 $add_query = ' LIMIT '
803 . (($limit_from > 0) ?
$limit_from . ', ' : '')
809 $is_view = PMA_Table
::isView($db, $table);
810 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
811 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
813 if (! $export_plugin->exportStructure(
814 $db, $table, $crlf, $err_url,
815 $is_view ?
'create_view' : 'create_table', $export_type,
816 $do_relation, $do_comments, $do_mime, $do_dates
821 // If this is an export of a single view, we have to export data;
822 // for example, a PDF report
823 // if it is a merge table, no data is exported
824 if (($GLOBALS[$what . '_structure_or_data'] == 'data'
825 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data')
826 && ! PMA_Table
::isMerge($db, $table)
828 if (! empty($sql_query)) {
829 // only preg_replace if needed
830 if (! empty($add_query)) {
831 // remove trailing semicolon before adding a LIMIT
832 $sql_query = preg_replace('%;\s*$%', '', $sql_query);
834 $local_query = $sql_query . $add_query;
835 PMA_DBI_select_db($db);
837 $local_query = 'SELECT * FROM ' . PMA_Util
::backquote($db)
838 . '.' . PMA_Util
::backquote($table) . $add_query;
840 if (! $export_plugin->exportData($db, $table, $crlf, $err_url, $local_query)) {
844 // now export the triggers (needs to be done after the data because
845 // triggers can modify already imported tables)
846 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
847 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
849 if (! $export_plugin->exportStructure(
850 $db, $table, $crlf, $err_url,
851 'triggers', $export_type,
852 $do_relation, $do_comments, $do_mime, $do_dates
857 if (! $export_plugin->exportDBFooter($db)) {
861 if (! $export_plugin->exportFooter()) {
868 if ($save_on_server && isset($message)) {
869 if ($export_type == 'server') {
870 $active_page = 'server_export.php';
871 include 'server_export.php';
872 } elseif ($export_type == 'database') {
873 $active_page = 'db_export.php';
874 include 'db_export.php';
876 $active_page = 'tbl_export.php';
877 include 'tbl_export.php';
883 * Send the dump as a file...
885 if (! empty($asfile)) {
886 // Convert the charset if required.
887 if ($output_charset_conversion) {
888 $dump_buffer = PMA_convert_string(
890 $GLOBALS['charset_of_file'],
895 // Do the compression
896 // 1. as a zipped file
897 if ($compression == 'zip') {
898 if (@function_exists
('gzcompress')) {
899 $zipfile = new ZipFile();
900 $zipfile->addFile($dump_buffer, substr($filename, 0, -4));
901 $dump_buffer = $zipfile->file();
903 } elseif ($compression == 'bzip2') {
904 // 2. as a bzipped file
905 if (@function_exists
('bzcompress')) {
906 $dump_buffer = bzcompress($dump_buffer);
908 } elseif ($compression == 'gzip' && PMA_gzencodeNeeded()) {
909 // 3. as a gzipped file
910 // without the optional parameter level because it bugs
911 $dump_buffer = gzencode($dump_buffer);
914 /* If we saved on server, we have to close file now */
915 if ($save_on_server) {
916 $write_result = @fwrite
($file_handle, $dump_buffer);
917 fclose($file_handle);
918 if (strlen($dump_buffer) > 0
919 && (! $write_result ||
($write_result != strlen($dump_buffer)))
921 $message = new PMA_Message(
922 __('Insufficient space to save the file %s.'),
927 $message = new PMA_Message(
928 __('Dump has been saved to file %s.'),
929 PMA_Message
::SUCCESS
,
934 if ($export_type == 'server') {
935 $active_page = 'server_export.php';
936 include_once 'server_export.php';
937 } elseif ($export_type == 'database') {
938 $active_page = 'db_export.php';
939 include_once 'db_export.php';
941 $active_page = 'tbl_export.php';
942 include_once 'tbl_export.php';
946 PMA_Response
::getInstance()->disable();
951 * Displays the dump...
953 * Close the html tags and add the footers if dump is displayed on screen
955 echo '</textarea>' . "\n"
960 echo '</div>' . "\n";
963 <script type
="text/javascript">
965 var $body = $
("body");
967 .width($body.width() - 50)
968 .height($body.height() - 100);