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
41 'htmlword_structure_or_data',
44 'mediawiki_structure_or_data',
47 'pdf_structure_or_data',
48 'odt_structure_or_data',
54 'codegen_structure_or_data',
60 'excel_structure_or_data',
61 'yaml_structure_or_data',
63 'ods_structure_or_data',
65 'json_structure_or_data',
66 'xml_structure_or_data',
67 'xml_export_functions',
68 'xml_export_procedures',
70 'xml_export_triggers',
72 'xml_export_contents',
73 'texytext_structure_or_data',
76 'phparray_structure_or_data',
77 'sql_include_comments',
82 'sql_use_transaction',
84 'sql_views_as_tables',
86 'sql_structure_or_data',
87 'sql_create_database',
89 'sql_procedure_function',
90 'sql_create_table_statements',
109 'csv_structure_or_data',
110 // csv_replace should have been here but we use it directly from $_POST
112 'latex_structure_or_data',
113 'latex_structure_caption',
114 'latex_structure_continued_caption',
115 'latex_structure_label',
120 'latex_data_caption',
121 'latex_data_continued_caption',
126 foreach ($post_params as $one_post_param) {
127 if (isset($_POST[$one_post_param])) {
128 $GLOBALS[$one_post_param] = $_POST[$one_post_param];
132 // sanitize this parameter which will be used below in a file inclusion
133 $what = PMA_securePath($what);
135 PMA_Util
::checkParameters(array('what', 'export_type'));
137 // export class instance, not array of properties, as before
138 $export_plugin = PMA_getPlugin(
141 'libraries/plugins/export/',
143 'export_type' => $export_type,
144 'single_table' => isset($single_table)
148 // Backward compatbility
152 if (! isset($export_plugin)) {
153 PMA_fatalError(__('Bad type!'));
157 * valid compression methods
159 $compression_methods = array(
166 * init and variable checking
168 $compression = false;
170 $save_on_server = false;
171 $buffer_needed = false;
173 // Is it a quick or custom export?
174 if ($_REQUEST['quick_or_custom'] == 'quick') {
175 $quick_export = true;
177 $quick_export = false;
180 if ($_REQUEST['output_format'] == 'astext') {
184 if (in_array($_REQUEST['compression'], $compression_methods)) {
185 $compression = $_REQUEST['compression'];
186 $buffer_needed = true;
188 if (($quick_export && ! empty($_REQUEST['quick_export_onserver']))
189 ||
(! $quick_export && ! empty($_REQUEST['onserver']))
192 $onserver = $_REQUEST['quick_export_onserver'];
194 $onserver = $_REQUEST['onserver'];
196 // Will we save dump on server?
197 $save_on_server = ! empty($cfg['SaveDir']) && $onserver;
201 // Does export require to be into file?
202 if ($export_plugin->getProperties()->getForceFile() != null && ! $asfile) {
203 $message = PMA_Message
::error(
204 __('Selected export type has to be saved in file!')
206 if ($export_type == 'server') {
207 $active_page = 'server_export.php';
208 include 'server_export.php';
209 } elseif ($export_type == 'database') {
210 $active_page = 'db_export.php';
211 include 'db_export.php';
213 $active_page = 'tbl_export.php';
214 include 'tbl_export.php';
219 // Generate error url and check for needed variables
220 if ($export_type == 'server') {
221 $err_url = 'server_export.php?' . PMA_generate_common_url();
222 } elseif ($export_type == 'database' && strlen($db)) {
223 $err_url = 'db_export.php?' . PMA_generate_common_url($db);
224 // Check if we have something to export
225 if (isset($table_select)) {
226 $tables = $table_select;
230 } elseif ($export_type == 'table' && strlen($db) && strlen($table)) {
231 $err_url = 'tbl_export.php?' . PMA_generate_common_url($db, $table);
233 PMA_fatalError(__('Bad parameters!'));
237 * Increase time limit for script execution and initializes some variables
239 @set_time_limit
($cfg['ExecTimeLimit']);
240 if (! empty($cfg['MemoryLimit'])) {
241 @ini_set
('memory_limit', $cfg['MemoryLimit']);
244 // Start with empty buffer
246 $dump_buffer_len = 0;
248 // We send fake headers to avoid browser timeout when buffering
249 $time_start = time();
253 * Detect ob_gzhandler
257 function PMA_isGzHandlerEnabled()
259 return in_array('ob_gzhandler', ob_list_handlers());
263 * Detect whether gzencode is needed; it might not be needed if
264 * the server is already compressing by itself
266 * @return bool Whether gzencode is needed
268 function PMA_gzencodeNeeded()
270 // Here, we detect Apache's mod_deflate so we bet that
271 // this module is active for this instance of phpMyAdmin
272 // and therefore, will gzip encode the content
273 if (@function_exists
('gzencode')
274 && ! @ini_get
('zlib.output_compression')
275 && ! (function_exists('apache_get_modules')
276 && in_array('mod_deflate', apache_get_modules()))
277 && ! PMA_isGzHandlerEnabled()
286 * Output handler for all exports, if needed buffering, it stores data into
287 * $dump_buffer, otherwise it prints thems out.
289 * @param string $line the insert statement
291 * @return bool Whether output succeeded
293 function PMA_exportOutputHandler($line)
295 global $time_start, $dump_buffer, $dump_buffer_len, $save_filename;
297 // Kanji encoding convert feature
298 if ($GLOBALS['output_kanji_conversion']) {
299 $line = PMA_Kanji_strConv(
302 isset($GLOBALS['xkana']) ?
$GLOBALS['xkana'] : ''
305 // If we have to buffer data, we will perform everything at once at the end
306 if ($GLOBALS['buffer_needed']) {
308 $dump_buffer .= $line;
309 if ($GLOBALS['onfly_compression']) {
311 $dump_buffer_len +
= strlen($line);
313 if ($dump_buffer_len > $GLOBALS['memory_limit']) {
314 if ($GLOBALS['output_charset_conversion']) {
315 $dump_buffer = PMA_convertString(
317 $GLOBALS['charset_of_file'],
322 if ($GLOBALS['compression'] == 'bzip2'
323 && @function_exists
('bzcompress')
325 $dump_buffer = bzcompress($dump_buffer);
326 } elseif ($GLOBALS['compression'] == 'gzip'
327 && PMA_gzencodeNeeded()
330 // without the optional parameter level because it bugs
331 $dump_buffer = gzencode($dump_buffer);
333 if ($GLOBALS['save_on_server']) {
334 $write_result = @fwrite
($GLOBALS['file_handle'], $dump_buffer);
335 if (! $write_result ||
($write_result != strlen($dump_buffer))) {
336 $GLOBALS['message'] = PMA_Message
::error(
337 __('Insufficient space to save the file %s.')
339 $GLOBALS['message']->addParam($save_filename);
346 $dump_buffer_len = 0;
350 if ($time_start >= $time_now +
30) {
351 $time_start = $time_now;
352 header('X-pmaPing: Pong');
356 if ($GLOBALS['asfile']) {
357 if ($GLOBALS['output_charset_conversion']) {
358 $line = PMA_convertString(
360 $GLOBALS['charset_of_file'],
364 if ($GLOBALS['save_on_server'] && strlen($line) > 0) {
365 $write_result = @fwrite
($GLOBALS['file_handle'], $line);
366 if (! $write_result ||
($write_result != strlen($line))) {
367 $GLOBALS['message'] = PMA_Message
::error(
368 __('Insufficient space to save the file %s.')
370 $GLOBALS['message']->addParam($save_filename);
374 if ($time_start >= $time_now +
30) {
375 $time_start = $time_now;
376 header('X-pmaPing: Pong');
379 // We export as file - output normally
383 // We export as html - replace special chars
384 echo htmlspecialchars($line);
388 } // end of the 'PMA_exportOutputHandler()' function
390 // Defines the default <CR><LF> format.
391 // For SQL always use \n as MySQL wants this on all platforms.
392 if ($what == 'sql') {
395 $crlf = PMA_Util
::whichCrlf();
398 $output_kanji_conversion = function_exists('PMA_Kanji_strConv') && $type != 'xls';
400 // Do we need to convert charset?
401 $output_charset_conversion = $asfile
402 && $GLOBALS['PMA_recoding_engine'] != PMA_CHARSET_NONE
403 && isset($charset_of_file) && $charset_of_file != 'utf-8'
406 // Use on the fly compression?
407 $onfly_compression = $GLOBALS['cfg']['CompressOnFly']
408 && ($compression == 'gzip' ||
$compression == 'bzip2');
409 if ($onfly_compression) {
410 $memory_limit = trim(@ini_get
('memory_limit'));
412 if (empty($memory_limit)) {
413 $memory_limit = 2 * 1024 * 1024;
416 if (strtolower(substr($memory_limit, -1)) == 'm') {
417 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024;
418 } elseif (strtolower(substr($memory_limit, -1)) == 'k') {
419 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024;
420 } elseif (strtolower(substr($memory_limit, -1)) == 'g') {
421 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024 * 1024;
423 $memory_limit = (int)$memory_limit;
426 // Some of memory is needed for other things and as threshold.
427 // During export I had allocated (see memory_get_usage function)
428 // approx 1.2MB so this comes from that.
429 if ($memory_limit > 1500000) {
430 $memory_limit -= 1500000;
433 // Some memory is needed for compression, assume 1/3
437 // Generate filename and mime type if needed
439 $pma_uri_parts = parse_url($cfg['PmaAbsoluteUri']);
440 if ($export_type == 'server') {
441 if (isset($remember_template)) {
442 $GLOBALS['PMA_Config']->setUserValue(
443 'pma_server_filename_template',
444 'Export/file_template_server',
448 } elseif ($export_type == 'database') {
449 if (isset($remember_template)) {
450 $GLOBALS['PMA_Config']->setUserValue(
451 'pma_db_filename_template',
452 'Export/file_template_database',
457 if (isset($remember_template)) {
458 $GLOBALS['PMA_Config']->setUserValue(
459 'pma_table_filename_template',
460 'Export/file_template_table',
465 $filename = PMA_Util
::expandUserString($filename_template);
466 // remove dots in filename (coming from either the template or already
467 // part of the filename) to avoid a remote code execution vulnerability
468 $filename = PMA_sanitizeFilename($filename, $replaceDots = true);
470 // Grab basic dump extension and mime type
471 // Check if the user already added extension;
472 // get the substring where the extension would be if it was included
473 $extension_start_pos = strlen($filename) - strlen(
474 $export_plugin->getProperties()->getExtension()
476 $user_extension = substr($filename, $extension_start_pos, strlen($filename));
477 $required_extension = "." . $export_plugin->getProperties()->getExtension();
478 if (strtolower($user_extension) != $required_extension) {
479 $filename .= $required_extension;
481 $mime_type = $export_plugin->getProperties()->getMimeType();
483 // If dump is going to be compressed, set correct mime_type and add
484 // compression to extension
485 if ($compression == 'bzip2') {
487 $mime_type = 'application/x-bzip2';
488 } elseif ($compression == 'gzip') {
490 $mime_type = 'application/x-gzip';
491 } elseif ($compression == 'zip') {
493 $mime_type = 'application/zip';
497 // Open file on server if needed
498 if ($save_on_server) {
499 $save_filename = PMA_Util
::userDir($cfg['SaveDir'])
500 . preg_replace('@[/\\\\]@', '_', $filename);
502 if (file_exists($save_filename)
503 && ((! $quick_export && empty($onserverover))
505 && $_REQUEST['quick_export_onserverover'] != 'saveitover'))
507 $message = PMA_Message
::error(
508 __('File %s already exists on server, change filename or check overwrite option.')
510 $message->addParam($save_filename);
512 if (is_file($save_filename) && ! is_writable($save_filename)) {
513 $message = PMA_Message
::error(
514 __('The web server does not have permission to save the file %s.')
516 $message->addParam($save_filename);
518 if (! $file_handle = @fopen
($save_filename, 'w')) {
519 $message = PMA_Message
::error(
520 __('The web server does not have permission to save the file %s.')
522 $message->addParam($save_filename);
526 if (isset($message)) {
527 if ($export_type == 'server') {
528 $active_page = 'server_export.php';
529 include 'server_export.php';
530 } elseif ($export_type == 'database') {
531 $active_page = 'db_export.php';
532 include 'db_export.php';
534 $active_page = 'tbl_export.php';
535 include 'tbl_export.php';
542 * Send headers depending on whether the user chose to download a dump file
545 if (! $save_on_server) {
548 // (avoid rewriting data containing HTML with anchors and forms;
549 // this was reported to happen under Plesk)
550 @ini_set
('url_rewriter.tags', '');
551 $filename = PMA_sanitizeFilename($filename);
553 PMA_downloadHeader($filename, $mime_type);
556 if ($export_type == 'database') {
557 $num_tables = count($tables);
558 if ($num_tables == 0) {
559 $message = PMA_Message
::error(__('No tables found in database.'));
560 $active_page = 'db_export.php';
561 include 'db_export.php';
565 $backup_cfgServer = $cfg['Server'];
566 $cfg['Server'] = $backup_cfgServer;
567 unset($backup_cfgServer);
568 echo "\n" . '<div style="text-align: ' . $cell_align_left . '">' . "\n";
569 //echo ' <pre>' . "\n";
572 * Displays a back button with all the $_REQUEST data in the URL
573 * (store in a variable to also display after the textarea)
575 $back_button = '<p>[ <a href="';
576 if ($export_type == 'server') {
577 $back_button .= 'server_export.php?' . PMA_generate_common_url();
578 } elseif ($export_type == 'database') {
579 $back_button .= 'db_export.php?' . PMA_generate_common_url($db);
581 $back_button .= 'tbl_export.php?' . PMA_generate_common_url($db, $table);
584 // Convert the multiple select elements from an array to a string
585 if ($export_type == 'server' && isset($_REQUEST['db_select'])) {
586 $_REQUEST['db_select'] = implode(",", $_REQUEST['db_select']);
587 } elseif ($export_type == 'database' && isset($_REQUEST['table_select'])) {
588 $_REQUEST['table_select'] = implode(",", $_REQUEST['table_select']);
591 foreach ($_REQUEST as $name => $value) {
592 $back_button .= '&' . urlencode($name) . '=' . urlencode($value);
594 $back_button .= '&repopulate=1">Back</a> ]</p>';
597 echo ' <form name="nofunction">' . "\n"
598 // remove auto-select for now: there is no way to select
599 // only a part of the text; anyway, it should obey
600 // $cfg['TextareaAutoSelect']
601 //. ' <textarea name="sqldump" cols="50" rows="30" onclick="this.select();" id="textSQLDUMP" wrap="OFF">' . "\n";
602 . ' <textarea name="sqldump" cols="50" rows="30" id="textSQLDUMP" wrap="OFF">' . "\n";
606 // Fake loop just to allow skip of remain of this code by break, I'd really
607 // need exceptions here :-)
610 // Add possibly some comments to export
611 if (! $export_plugin->exportHeader($db)) {
615 // Will we need relation & co. setup?
616 $do_relation = isset($GLOBALS[$what . '_relation']);
617 $do_comments = isset($GLOBALS[$what . '_include_comments']);
618 $do_mime = isset($GLOBALS[$what . '_mime']);
619 if ($do_relation ||
$do_comments ||
$do_mime) {
620 $cfgRelation = PMA_getRelationsParam();
623 include_once 'libraries/transformations.lib.php';
626 // Include dates in export?
627 $do_dates = isset($GLOBALS[$what . '_dates']);
632 // Gets the number of tables if a dump of a database has been required
633 if ($export_type == 'server') {
634 if (isset($db_select)) {
635 $tmp_select = implode($db_select, '|');
636 $tmp_select = '|' . $tmp_select . '|';
638 // Walk over databases
639 foreach ($GLOBALS['pma']->databases
as $current_db) {
640 if (isset($tmp_select)
641 && strpos(' ' . $tmp_select, '|' . $current_db . '|')
643 if (! $export_plugin->exportDBHeader($current_db)) {
646 if (! $export_plugin->exportDBCreate($current_db)) {
649 if (method_exists($export_plugin, 'exportRoutines')
650 && strpos($GLOBALS['sql_structure_or_data'], 'structure') !== false
651 && isset($GLOBALS['sql_procedure_function'])
653 $export_plugin->exportRoutines($current_db);
656 $tables = $GLOBALS['dbi']->getTables($current_db);
658 foreach ($tables as $table) {
659 // if this is a view, collect it for later;
660 // views must be exported after the tables
661 $is_view = PMA_Table
::isView($current_db, $table);
665 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
666 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
668 // for a view, export a stand-in definition of the table
669 // to resolve view dependencies
670 if (! $export_plugin->exportStructure(
671 $current_db, $table, $crlf, $err_url,
672 $is_view ?
'stand_in' : 'create_table', $export_type,
673 $do_relation, $do_comments, $do_mime, $do_dates
678 // if this is a view or a merge table, don't export data
679 if (($GLOBALS[$what . '_structure_or_data'] == 'data'
680 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data')
681 && ! ($is_view || PMA_Table
::isMerge($current_db, $table))
683 $local_query = 'SELECT * FROM ' . PMA_Util
::backquote($current_db)
684 . '.' . PMA_Util
::backquote($table);
685 if (! $export_plugin->exportData($current_db, $table, $crlf, $err_url, $local_query)) {
689 // now export the triggers (needs to be done after the data
690 // because triggers can modify already imported tables)
691 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
692 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
694 if (! $export_plugin->exportStructure(
695 $current_db, $table, $crlf, $err_url,
696 'triggers', $export_type,
697 $do_relation, $do_comments, $do_mime, $do_dates
703 foreach ($views as $view) {
704 // no data export for a view
705 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
706 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
708 if (! $export_plugin->exportStructure(
709 $current_db, $view, $crlf, $err_url,
710 'create_view', $export_type,
711 $do_relation, $do_comments, $do_mime, $do_dates
717 if (! $export_plugin->exportDBFooter($current_db)) {
722 } elseif ($export_type == 'database') {
723 if (! $export_plugin->exportDBHeader($db)) {
726 if (! $export_plugin->exportDBCreate($db)) {
730 if (method_exists($export_plugin, 'exportRoutines')
731 && strpos($GLOBALS['sql_structure_or_data'], 'structure') !== false
732 && isset($GLOBALS['sql_procedure_function'])
734 $export_plugin->exportRoutines($db);
739 // $tables contains the choices from the user (via $table_select)
740 foreach ($tables as $table) {
741 // if this is a view, collect it for later; views must be exported after
743 $is_view = PMA_Table
::isView($db, $table);
747 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
748 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
750 // for a view, export a stand-in definition of the table
751 // to resolve view dependencies
752 if (! $export_plugin->exportStructure(
753 $db, $table, $crlf, $err_url,
754 $is_view ?
'stand_in' : 'create_table', $export_type,
755 $do_relation, $do_comments, $do_mime, $do_dates
760 // if this is a view or a merge table, don't export data
761 if (($GLOBALS[$what . '_structure_or_data'] == 'data'
762 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data')
763 && ! ($is_view || PMA_Table
::isMerge($db, $table))
765 $local_query = 'SELECT * FROM ' . PMA_Util
::backquote($db)
766 . '.' . PMA_Util
::backquote($table);
767 if (! $export_plugin->exportData($db, $table, $crlf, $err_url, $local_query)) {
771 // now export the triggers (needs to be done after the data because
772 // triggers can modify already imported tables)
773 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
774 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
776 if (! $export_plugin->exportStructure(
777 $db, $table, $crlf, $err_url,
778 'triggers', $export_type,
779 $do_relation, $do_comments, $do_mime, $do_dates
785 foreach ($views as $view) {
786 // no data export for a view
787 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
788 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
790 if (! $export_plugin->exportStructure(
791 $db, $view, $crlf, $err_url,
792 'create_view', $export_type,
793 $do_relation, $do_comments, $do_mime, $do_dates
800 if (! $export_plugin->exportDBFooter($db)) {
804 if (! $export_plugin->exportDBHeader($db)) {
807 // We export just one table
808 // $allrows comes from the form when "Dump all rows" has been selected
809 if (isset($allrows) && $allrows == '0' && $limit_to > 0 && $limit_from >= 0) {
810 $add_query = ' LIMIT '
811 . (($limit_from > 0) ?
$limit_from . ', ' : '')
817 $is_view = PMA_Table
::isView($db, $table);
818 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
819 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
821 if (! $export_plugin->exportStructure(
822 $db, $table, $crlf, $err_url,
823 $is_view ?
'create_view' : 'create_table', $export_type,
824 $do_relation, $do_comments, $do_mime, $do_dates
829 // If this is an export of a single view, we have to export data;
830 // for example, a PDF report
831 // if it is a merge table, no data is exported
832 if (($GLOBALS[$what . '_structure_or_data'] == 'data'
833 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data')
834 && ! PMA_Table
::isMerge($db, $table)
836 if (! empty($sql_query)) {
837 // only preg_replace if needed
838 if (! empty($add_query)) {
839 // remove trailing semicolon before adding a LIMIT
840 $sql_query = preg_replace('%;\s*$%', '', $sql_query);
842 $local_query = $sql_query . $add_query;
843 $GLOBALS['dbi']->selectDb($db);
845 $local_query = 'SELECT * FROM ' . PMA_Util
::backquote($db)
846 . '.' . PMA_Util
::backquote($table) . $add_query;
848 if (! $export_plugin->exportData($db, $table, $crlf, $err_url, $local_query)) {
852 // now export the triggers (needs to be done after the data because
853 // triggers can modify already imported tables)
854 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
855 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
857 if (! $export_plugin->exportStructure(
858 $db, $table, $crlf, $err_url,
859 'triggers', $export_type,
860 $do_relation, $do_comments, $do_mime, $do_dates
865 if (! $export_plugin->exportDBFooter($db)) {
869 if (! $export_plugin->exportFooter()) {
876 if ($save_on_server && isset($message)) {
877 if ($export_type == 'server') {
878 $active_page = 'server_export.php';
879 include 'server_export.php';
880 } elseif ($export_type == 'database') {
881 $active_page = 'db_export.php';
882 include 'db_export.php';
884 $active_page = 'tbl_export.php';
885 include 'tbl_export.php';
891 * Send the dump as a file...
893 if (! empty($asfile)) {
894 // Convert the charset if required.
895 if ($output_charset_conversion) {
896 $dump_buffer = PMA_convertString(
898 $GLOBALS['charset_of_file'],
903 // Do the compression
904 // 1. as a zipped file
905 if ($compression == 'zip') {
906 if (@function_exists
('gzcompress')) {
907 $zipfile = new ZipFile();
908 $zipfile->addFile($dump_buffer, substr($filename, 0, -4));
909 $dump_buffer = $zipfile->file();
911 } elseif ($compression == 'bzip2') {
912 // 2. as a bzipped file
913 if (@function_exists
('bzcompress')) {
914 $dump_buffer = bzcompress($dump_buffer);
916 } elseif ($compression == 'gzip' && PMA_gzencodeNeeded()) {
917 // 3. as a gzipped file
918 // without the optional parameter level because it bugs
919 $dump_buffer = gzencode($dump_buffer);
922 /* If we saved on server, we have to close file now */
923 if ($save_on_server) {
924 $write_result = @fwrite
($file_handle, $dump_buffer);
925 fclose($file_handle);
926 if (strlen($dump_buffer) > 0
927 && (! $write_result ||
($write_result != strlen($dump_buffer)))
929 $message = new PMA_Message(
930 __('Insufficient space to save the file %s.'),
935 $message = new PMA_Message(
936 __('Dump has been saved to file %s.'),
937 PMA_Message
::SUCCESS
,
942 if ($export_type == 'server') {
943 $active_page = 'server_export.php';
944 include_once 'server_export.php';
945 } elseif ($export_type == 'database') {
946 $active_page = 'db_export.php';
947 include_once 'db_export.php';
949 $active_page = 'tbl_export.php';
950 include_once 'tbl_export.php';
954 PMA_Response
::getInstance()->disable();
959 * Displays the dump...
961 * Close the html tags and add the footers if dump is displayed on screen
963 echo '</textarea>' . "\n"
968 echo '</div>' . "\n";
971 <script type
="text/javascript">
973 var $body = $
("body");
975 .width($body.width() - 50)
976 .height($body.height() - 100);