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',
59 'excel_structure_or_data',
60 'yaml_structure_or_data',
62 'ods_structure_or_data',
64 'json_structure_or_data',
65 'xml_structure_or_data',
66 'xml_export_functions',
67 'xml_export_procedures',
69 'xml_export_triggers',
71 'xml_export_contents',
72 'texytext_structure_or_data',
75 'phparray_structure_or_data',
76 'sql_include_comments',
81 'sql_use_transaction',
84 'sql_structure_or_data',
86 'sql_procedure_function',
87 'sql_create_table_statements',
105 'csv_structure_or_data',
106 // csv_replace should have been here but we use it directly from $_POST
108 'latex_structure_or_data',
109 'latex_structure_caption',
110 'latex_structure_continued_caption',
111 'latex_structure_label',
116 'latex_data_caption',
117 'latex_data_continued_caption',
122 foreach ($post_params as $one_post_param) {
123 if (isset($_POST[$one_post_param])) {
124 $GLOBALS[$one_post_param] = $_POST[$one_post_param];
128 // sanitize this parameter which will be used below in a file inclusion
129 $what = PMA_securePath($what);
131 PMA_Util
::checkParameters(array('what', 'export_type'));
133 // export class instance, not array of properties, as before
134 $export_plugin = PMA_getPlugin(
137 'libraries/plugins/export/',
139 'export_type' => $export_type,
140 'single_table' => isset($single_table)
144 // Backward compatbility
148 if (! isset($export_plugin)) {
149 PMA_fatalError(__('Bad type!'));
153 * valid compression methods
155 $compression_methods = array(
162 * init and variable checking
164 $compression = false;
166 $save_on_server = false;
167 $buffer_needed = false;
169 // Is it a quick or custom export?
170 if ($_REQUEST['quick_or_custom'] == 'quick') {
171 $quick_export = true;
173 $quick_export = false;
176 if ($_REQUEST['output_format'] == 'astext') {
180 if (in_array($_REQUEST['compression'], $compression_methods)) {
181 $compression = $_REQUEST['compression'];
182 $buffer_needed = true;
184 if (($quick_export && ! empty($_REQUEST['quick_export_onserver']))
185 ||
(! $quick_export && ! empty($_REQUEST['onserver']))
188 $onserver = $_REQUEST['quick_export_onserver'];
190 $onserver = $_REQUEST['onserver'];
192 // Will we save dump on server?
193 $save_on_server = ! empty($cfg['SaveDir']) && $onserver;
197 // Does export require to be into file?
198 if ($export_plugin->getProperties()->getForceFile() != null && ! $asfile) {
199 $message = PMA_Message
::error(
200 __('Selected export type has to be saved in file!')
202 if ($export_type == 'server') {
203 $active_page = 'server_export.php';
204 include 'server_export.php';
205 } elseif ($export_type == 'database') {
206 $active_page = 'db_export.php';
207 include 'db_export.php';
209 $active_page = 'tbl_export.php';
210 include 'tbl_export.php';
215 // Generate error url and check for needed variables
216 if ($export_type == 'server') {
217 $err_url = 'server_export.php?' . PMA_generate_common_url();
218 } elseif ($export_type == 'database' && strlen($db)) {
219 $err_url = 'db_export.php?' . PMA_generate_common_url($db);
220 // Check if we have something to export
221 if (isset($table_select)) {
222 $tables = $table_select;
226 } elseif ($export_type == 'table' && strlen($db) && strlen($table)) {
227 $err_url = 'tbl_export.php?' . PMA_generate_common_url($db, $table);
229 PMA_fatalError(__('Bad parameters!'));
233 * Increase time limit for script execution and initializes some variables
235 @set_time_limit
($cfg['ExecTimeLimit']);
236 if (! empty($cfg['MemoryLimit'])) {
237 @ini_set
('memory_limit', $cfg['MemoryLimit']);
240 // Start with empty buffer
242 $dump_buffer_len = 0;
244 // We send fake headers to avoid browser timeout when buffering
245 $time_start = time();
249 * Detect ob_gzhandler
253 function PMA_isGzHandlerEnabled()
255 return in_array('ob_gzhandler', ob_list_handlers());
259 * Detect whether gzencode is needed; it might not be needed if
260 * the server is already compressing by itself
262 * @return bool Whether gzencode is needed
264 function PMA_gzencodeNeeded()
266 if (@function_exists
('gzencode')
267 && ! @ini_get
('zlib.output_compression')
268 // Here, we detect Apache's mod_deflate so we bet that
269 // this module is active for this instance of phpMyAdmin
270 // and therefore, will gzip encode the content
271 && ! (function_exists('apache_get_modules')
272 && in_array('mod_deflate', apache_get_modules()))
273 && ! PMA_isGzHandlerEnabled()
282 * Output handler for all exports, if needed buffering, it stores data into
283 * $dump_buffer, otherwise it prints thems out.
285 * @param string $line the insert statement
287 * @return bool Whether output succeeded
289 function PMA_exportOutputHandler($line)
291 global $time_start, $dump_buffer, $dump_buffer_len, $save_filename;
293 // Kanji encoding convert feature
294 if ($GLOBALS['output_kanji_conversion']) {
295 $line = PMA_kanji_str_conv(
298 isset($GLOBALS['xkana']) ?
$GLOBALS['xkana'] : ''
301 // If we have to buffer data, we will perform everything at once at the end
302 if ($GLOBALS['buffer_needed']) {
304 $dump_buffer .= $line;
305 if ($GLOBALS['onfly_compression']) {
307 $dump_buffer_len +
= strlen($line);
309 if ($dump_buffer_len > $GLOBALS['memory_limit']) {
310 if ($GLOBALS['output_charset_conversion']) {
311 $dump_buffer = PMA_convert_string(
313 $GLOBALS['charset_of_file'],
318 if ($GLOBALS['compression'] == 'bzip2'
319 && @function_exists
('bzcompress')
321 $dump_buffer = bzcompress($dump_buffer);
322 } elseif ($GLOBALS['compression'] == 'gzip'
323 && PMA_gzencodeNeeded()
326 // without the optional parameter level because it bugs
327 $dump_buffer = gzencode($dump_buffer);
329 if ($GLOBALS['save_on_server']) {
330 $write_result = @fwrite
($GLOBALS['file_handle'], $dump_buffer);
331 if (! $write_result ||
($write_result != strlen($dump_buffer))) {
332 $GLOBALS['message'] = PMA_Message
::error(
333 __('Insufficient space to save the file %s.')
335 $GLOBALS['message']->addParam($save_filename);
342 $dump_buffer_len = 0;
346 if ($time_start >= $time_now +
30) {
347 $time_start = $time_now;
348 header('X-pmaPing: Pong');
352 if ($GLOBALS['asfile']) {
353 if ($GLOBALS['output_charset_conversion']) {
354 $line = PMA_convert_string(
356 $GLOBALS['charset_of_file'],
360 if ($GLOBALS['save_on_server'] && strlen($line) > 0) {
361 $write_result = @fwrite
($GLOBALS['file_handle'], $line);
362 if (! $write_result ||
($write_result != strlen($line))) {
363 $GLOBALS['message'] = PMA_Message
::error(
364 __('Insufficient space to save the file %s.')
366 $GLOBALS['message']->addParam($save_filename);
370 if ($time_start >= $time_now +
30) {
371 $time_start = $time_now;
372 header('X-pmaPing: Pong');
375 // We export as file - output normally
379 // We export as html - replace special chars
380 echo htmlspecialchars($line);
384 } // end of the 'PMA_exportOutputHandler()' function
386 // Defines the default <CR><LF> format.
387 // For SQL always use \n as MySQL wants this on all platforms.
388 if ($what == 'sql') {
391 $crlf = PMA_Util
::whichCrlf();
394 $output_kanji_conversion = function_exists('PMA_kanji_str_conv') && $type != 'xls';
396 // Do we need to convert charset?
397 $output_charset_conversion = $asfile
398 && $GLOBALS['PMA_recoding_engine'] != PMA_CHARSET_NONE
399 && isset($charset_of_file) && $charset_of_file != 'utf-8'
402 // Use on the fly compression?
403 $onfly_compression = $GLOBALS['cfg']['CompressOnFly']
404 && ($compression == 'gzip' ||
$compression == 'bzip2');
405 if ($onfly_compression) {
406 $memory_limit = trim(@ini_get
('memory_limit'));
408 if (empty($memory_limit)) {
409 $memory_limit = 2 * 1024 * 1024;
412 if (strtolower(substr($memory_limit, -1)) == 'm') {
413 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024;
414 } elseif (strtolower(substr($memory_limit, -1)) == 'k') {
415 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024;
416 } elseif (strtolower(substr($memory_limit, -1)) == 'g') {
417 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024 * 1024;
419 $memory_limit = (int)$memory_limit;
422 // Some of memory is needed for other thins and as treshold.
423 // Nijel: During export I had allocated (see memory_get_usage function)
424 // approx 1.2MB so this comes from that.
425 if ($memory_limit > 1500000) {
426 $memory_limit -= 1500000;
429 // Some memory is needed for compression, assume 1/3
433 // Generate filename and mime type if needed
435 $pma_uri_parts = parse_url($cfg['PmaAbsoluteUri']);
436 if ($export_type == 'server') {
437 if (isset($remember_template)) {
438 $GLOBALS['PMA_Config']->setUserValue(
439 'pma_server_filename_template',
440 'Export/file_template_server',
444 } elseif ($export_type == 'database') {
445 if (isset($remember_template)) {
446 $GLOBALS['PMA_Config']->setUserValue(
447 'pma_db_filename_template',
448 'Export/file_template_database',
453 if (isset($remember_template)) {
454 $GLOBALS['PMA_Config']->setUserValue(
455 'pma_table_filename_template',
456 'Export/file_template_table',
461 $filename = PMA_Util
::expandUserString($filename_template);
462 // remove dots in filename (coming from either the template or already
463 // part of the filename) to avoid a remote code execution vulnerability
464 $filename = PMA_sanitizeFilename($filename, $replaceDots = true);
466 // Grab basic dump extension and mime type
467 // Check if the user already added extension;
468 // get the substring where the extension would be if it was included
469 $extension_start_pos = strlen($filename) - strlen(
470 $export_plugin->getProperties()->getExtension()
472 $user_extension = substr($filename, $extension_start_pos, strlen($filename));
473 $required_extension = "." . $export_plugin->getProperties()->getExtension();
474 if (strtolower($user_extension) != $required_extension) {
475 $filename .= $required_extension;
477 $mime_type = $export_plugin->getProperties()->getMimeType();
479 // If dump is going to be compressed, set correct mime_type and add
480 // compression to extension
481 if ($compression == 'bzip2') {
483 $mime_type = 'application/x-bzip2';
484 } elseif ($compression == 'gzip') {
486 $mime_type = 'application/x-gzip';
487 } elseif ($compression == 'zip') {
489 $mime_type = 'application/zip';
493 // Open file on server if needed
494 if ($save_on_server) {
495 $save_filename = PMA_Util
::userDir($cfg['SaveDir'])
496 . preg_replace('@[/\\\\]@', '_', $filename);
498 if (file_exists($save_filename)
499 && ((! $quick_export && empty($onserverover))
501 && $_REQUEST['quick_export_onserverover'] != 'saveitover'))
503 $message = PMA_Message
::error(
504 __('File %s already exists on server, change filename or check overwrite option.')
506 $message->addParam($save_filename);
508 if (is_file($save_filename) && ! is_writable($save_filename)) {
509 $message = PMA_Message
::error(
510 __('The web server does not have permission to save the file %s.')
512 $message->addParam($save_filename);
514 if (! $file_handle = @fopen
($save_filename, 'w')) {
515 $message = PMA_Message
::error(
516 __('The web server does not have permission to save the file %s.')
518 $message->addParam($save_filename);
522 if (isset($message)) {
523 if ($export_type == 'server') {
524 $active_page = 'server_export.php';
525 include 'server_export.php';
526 } elseif ($export_type == 'database') {
527 $active_page = 'db_export.php';
528 include 'db_export.php';
530 $active_page = 'tbl_export.php';
531 include 'tbl_export.php';
538 * Send headers depending on whether the user chose to download a dump file
541 if (! $save_on_server) {
544 // (avoid rewriting data containing HTML with anchors and forms;
545 // this was reported to happen under Plesk)
546 @ini_set
('url_rewriter.tags', '');
547 $filename = PMA_sanitizeFilename($filename);
549 PMA_downloadHeader($filename, $mime_type);
552 if ($export_type == 'database') {
553 $num_tables = count($tables);
554 if ($num_tables == 0) {
555 $message = PMA_Message
::error(__('No tables found in database.'));
556 $active_page = 'db_export.php';
557 include 'db_export.php';
561 $backup_cfgServer = $cfg['Server'];
562 $cfg['Server'] = $backup_cfgServer;
563 unset($backup_cfgServer);
564 echo "\n" . '<div style="text-align: ' . $cell_align_left . '">' . "\n";
565 //echo ' <pre>' . "\n";
568 * Displays a back button with all the $_REQUEST data in the URL
569 * (store in a variable to also display after the textarea)
571 $back_button = '<p>[ <a href="';
572 if ($export_type == 'server') {
573 $back_button .= 'server_export.php?' . PMA_generate_common_url();
574 } elseif ($export_type == 'database') {
575 $back_button .= 'db_export.php?' . PMA_generate_common_url($db);
577 $back_button .= 'tbl_export.php?' . PMA_generate_common_url($db, $table);
580 // Convert the multiple select elements from an array to a string
581 if ($export_type == 'server' && isset($_REQUEST['db_select'])) {
582 $_REQUEST['db_select'] = implode(",", $_REQUEST['db_select']);
583 } elseif ($export_type == 'database' && isset($_REQUEST['table_select'])) {
584 $_REQUEST['table_select'] = implode(",", $_REQUEST['table_select']);
587 foreach ($_REQUEST as $name => $value) {
588 $back_button .= '&' . urlencode($name) . '=' . urlencode($value);
590 $back_button .= '&repopulate=1">Back</a> ]</p>';
593 echo ' <form name="nofunction">' . "\n"
594 // remove auto-select for now: there is no way to select
595 // only a part of the text; anyway, it should obey
596 // $cfg['TextareaAutoSelect']
597 //. ' <textarea name="sqldump" cols="50" rows="30" onclick="this.select();" id="textSQLDUMP" wrap="OFF">' . "\n";
598 . ' <textarea name="sqldump" cols="50" rows="30" id="textSQLDUMP" wrap="OFF">' . "\n";
602 // Fake loop just to allow skip of remain of this code by break, I'd really
603 // need exceptions here :-)
606 // Add possibly some comments to export
607 if (! $export_plugin->exportHeader($db)) {
611 // Will we need relation & co. setup?
612 $do_relation = isset($GLOBALS[$what . '_relation']);
613 $do_comments = isset($GLOBALS[$what . '_include_comments']);
614 $do_mime = isset($GLOBALS[$what . '_mime']);
615 if ($do_relation ||
$do_comments ||
$do_mime) {
616 $cfgRelation = PMA_getRelationsParam();
619 include_once 'libraries/transformations.lib.php';
622 // Include dates in export?
623 $do_dates = isset($GLOBALS[$what . '_dates']);
628 // Gets the number of tables if a dump of a database has been required
629 if ($export_type == 'server') {
630 if (isset($db_select)) {
631 $tmp_select = implode($db_select, '|');
632 $tmp_select = '|' . $tmp_select . '|';
634 // Walk over databases
635 foreach ($GLOBALS['pma']->databases
as $current_db) {
636 if (isset($tmp_select)
637 && strpos(' ' . $tmp_select, '|' . $current_db . '|')
639 if (! $export_plugin->exportDBHeader($current_db)) {
642 if (! $export_plugin->exportDBCreate($current_db)) {
645 if (method_exists($export_plugin, 'exportRoutines')
646 && strpos($GLOBALS['sql_structure_or_data'], 'structure') !== false
647 && isset($GLOBALS['sql_procedure_function'])
649 $export_plugin->exportRoutines($current_db);
652 $tables = PMA_DBI_get_tables($current_db);
654 foreach ($tables as $table) {
655 // if this is a view, collect it for later;
656 // views must be exported after the tables
657 $is_view = PMA_Table
::isView($current_db, $table);
661 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
662 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
664 // for a view, export a stand-in definition of the table
665 // to resolve view dependencies
666 if (! $export_plugin->exportStructure(
667 $current_db, $table, $crlf, $err_url,
668 $is_view ?
'stand_in' : 'create_table', $export_type,
669 $do_relation, $do_comments, $do_mime, $do_dates
674 // if this is a view or a merge table, don't export data
675 if (($GLOBALS[$what . '_structure_or_data'] == 'data'
676 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data')
677 && ! ($is_view || PMA_Table
::isMerge($current_db, $table))
679 $local_query = 'SELECT * FROM ' . PMA_Util
::backquote($current_db)
680 . '.' . PMA_Util
::backquote($table);
681 if (! $export_plugin->exportData($current_db, $table, $crlf, $err_url, $local_query)) {
685 // now export the triggers (needs to be done after the data
686 // because triggers can modify already imported tables)
687 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
688 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
690 if (! $export_plugin->exportStructure(
691 $current_db, $table, $crlf, $err_url,
692 'triggers', $export_type,
693 $do_relation, $do_comments, $do_mime, $do_dates
699 foreach ($views as $view) {
700 // no data export for a view
701 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
702 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
704 if (! $export_plugin->exportStructure(
705 $current_db, $view, $crlf, $err_url,
706 'create_view', $export_type,
707 $do_relation, $do_comments, $do_mime, $do_dates
713 if (! $export_plugin->exportDBFooter($current_db)) {
718 } elseif ($export_type == 'database') {
719 if (! $export_plugin->exportDBHeader($db)) {
722 if (! $export_plugin->exportDBCreate($db)) {
726 if (method_exists($export_plugin, 'exportRoutines')
727 && strpos($GLOBALS['sql_structure_or_data'], 'structure') !== false
728 && isset($GLOBALS['sql_procedure_function'])
730 $export_plugin->exportRoutines($db);
735 // $tables contains the choices from the user (via $table_select)
736 foreach ($tables as $table) {
737 // if this is a view, collect it for later; views must be exported after
739 $is_view = PMA_Table
::isView($db, $table);
743 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
744 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
746 // for a view, export a stand-in definition of the table
747 // to resolve view dependencies
748 if (! $export_plugin->exportStructure(
749 $db, $table, $crlf, $err_url,
750 $is_view ?
'stand_in' : 'create_table', $export_type,
751 $do_relation, $do_comments, $do_mime, $do_dates
756 // if this is a view or a merge table, don't export data
757 if (($GLOBALS[$what . '_structure_or_data'] == 'data'
758 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data')
759 && ! ($is_view || PMA_Table
::isMerge($db, $table))
761 $local_query = 'SELECT * FROM ' . PMA_Util
::backquote($db)
762 . '.' . PMA_Util
::backquote($table);
763 if (! $export_plugin->exportData($db, $table, $crlf, $err_url, $local_query)) {
767 // now export the triggers (needs to be done after the data because
768 // triggers can modify already imported tables)
769 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
770 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
772 if (! $export_plugin->exportStructure(
773 $db, $table, $crlf, $err_url,
774 'triggers', $export_type,
775 $do_relation, $do_comments, $do_mime, $do_dates
781 foreach ($views as $view) {
782 // no data export for a view
783 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
784 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
786 if (! $export_plugin->exportStructure(
787 $db, $view, $crlf, $err_url,
788 'create_view', $export_type,
789 $do_relation, $do_comments, $do_mime, $do_dates
796 if (! $export_plugin->exportDBFooter($db)) {
800 if (! $export_plugin->exportDBHeader($db)) {
803 // We export just one table
804 // $allrows comes from the form when "Dump all rows" has been selected
805 if (isset($allrows) && $allrows == '0' && $limit_to > 0 && $limit_from >= 0) {
806 $add_query = ' LIMIT '
807 . (($limit_from > 0) ?
$limit_from . ', ' : '')
813 $is_view = PMA_Table
::isView($db, $table);
814 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
815 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
817 if (! $export_plugin->exportStructure(
818 $db, $table, $crlf, $err_url,
819 $is_view ?
'create_view' : 'create_table', $export_type,
820 $do_relation, $do_comments, $do_mime, $do_dates
825 // If this is an export of a single view, we have to export data;
826 // for example, a PDF report
827 // if it is a merge table, no data is exported
828 if (($GLOBALS[$what . '_structure_or_data'] == 'data'
829 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data')
830 && ! PMA_Table
::isMerge($db, $table)
832 if (! empty($sql_query)) {
833 // only preg_replace if needed
834 if (! empty($add_query)) {
835 // remove trailing semicolon before adding a LIMIT
836 $sql_query = preg_replace('%;\s*$%', '', $sql_query);
838 $local_query = $sql_query . $add_query;
839 PMA_DBI_select_db($db);
841 $local_query = 'SELECT * FROM ' . PMA_Util
::backquote($db)
842 . '.' . PMA_Util
::backquote($table) . $add_query;
844 if (! $export_plugin->exportData($db, $table, $crlf, $err_url, $local_query)) {
848 // now export the triggers (needs to be done after the data because
849 // triggers can modify already imported tables)
850 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
851 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
853 if (! $export_plugin->exportStructure(
854 $db, $table, $crlf, $err_url,
855 'triggers', $export_type,
856 $do_relation, $do_comments, $do_mime, $do_dates
861 if (! $export_plugin->exportDBFooter($db)) {
865 if (! $export_plugin->exportFooter()) {
872 if ($save_on_server && isset($message)) {
873 if ($export_type == 'server') {
874 $active_page = 'server_export.php';
875 include 'server_export.php';
876 } elseif ($export_type == 'database') {
877 $active_page = 'db_export.php';
878 include 'db_export.php';
880 $active_page = 'tbl_export.php';
881 include 'tbl_export.php';
887 * Send the dump as a file...
889 if (! empty($asfile)) {
890 // Convert the charset if required.
891 if ($output_charset_conversion) {
892 $dump_buffer = PMA_convert_string(
894 $GLOBALS['charset_of_file'],
899 // Do the compression
900 // 1. as a zipped file
901 if ($compression == 'zip') {
902 if (@function_exists
('gzcompress')) {
903 $zipfile = new ZipFile();
904 $zipfile->addFile($dump_buffer, substr($filename, 0, -4));
905 $dump_buffer = $zipfile->file();
907 } elseif ($compression == 'bzip2') {
908 // 2. as a bzipped file
909 if (@function_exists
('bzcompress')) {
910 $dump_buffer = bzcompress($dump_buffer);
912 } elseif ($compression == 'gzip' && PMA_gzencodeNeeded()) {
913 // 3. as a gzipped file
914 // without the optional parameter level because it bugs
915 $dump_buffer = gzencode($dump_buffer);
918 /* If we saved on server, we have to close file now */
919 if ($save_on_server) {
920 $write_result = @fwrite
($file_handle, $dump_buffer);
921 fclose($file_handle);
922 if (strlen($dump_buffer) > 0
923 && (! $write_result ||
($write_result != strlen($dump_buffer)))
925 $message = new PMA_Message(
926 __('Insufficient space to save the file %s.'),
931 $message = new PMA_Message(
932 __('Dump has been saved to file %s.'),
933 PMA_Message
::SUCCESS
,
938 if ($export_type == 'server') {
939 $active_page = 'server_export.php';
940 include_once 'server_export.php';
941 } elseif ($export_type == 'database') {
942 $active_page = 'db_export.php';
943 include_once 'db_export.php';
945 $active_page = 'tbl_export.php';
946 include_once 'tbl_export.php';
950 PMA_Response
::getInstance()->disable();
955 * Displays the dump...
957 * Close the html tags and add the footers if dump is displayed on screen
959 echo '</textarea>' . "\n"
964 echo '</div>' . "\n";
967 <script type
="text/javascript">
969 var $body = $
("body");
971 .width($body.width() - 50)
972 .height($body.height() - 100);