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',
85 'sql_structure_or_data',
87 'sql_procedure_function',
88 'sql_create_table_statements',
107 'csv_structure_or_data',
108 // csv_replace should have been here but we use it directly from $_POST
110 'latex_structure_or_data',
111 'latex_structure_caption',
112 'latex_structure_continued_caption',
113 'latex_structure_label',
118 'latex_data_caption',
119 'latex_data_continued_caption',
124 foreach ($post_params as $one_post_param) {
125 if (isset($_POST[$one_post_param])) {
126 $GLOBALS[$one_post_param] = $_POST[$one_post_param];
130 // sanitize this parameter which will be used below in a file inclusion
131 $what = PMA_securePath($what);
133 PMA_Util
::checkParameters(array('what', 'export_type'));
135 // export class instance, not array of properties, as before
136 $export_plugin = PMA_getPlugin(
139 'libraries/plugins/export/',
141 'export_type' => $export_type,
142 'single_table' => isset($single_table)
146 // Backward compatbility
150 if (! isset($export_plugin)) {
151 PMA_fatalError(__('Bad type!'));
155 * valid compression methods
157 $compression_methods = array(
164 * init and variable checking
166 $compression = false;
168 $save_on_server = false;
169 $buffer_needed = false;
171 // Is it a quick or custom export?
172 if ($_REQUEST['quick_or_custom'] == 'quick') {
173 $quick_export = true;
175 $quick_export = false;
178 if ($_REQUEST['output_format'] == 'astext') {
182 if (in_array($_REQUEST['compression'], $compression_methods)) {
183 $compression = $_REQUEST['compression'];
184 $buffer_needed = true;
186 if (($quick_export && ! empty($_REQUEST['quick_export_onserver']))
187 ||
(! $quick_export && ! empty($_REQUEST['onserver']))
190 $onserver = $_REQUEST['quick_export_onserver'];
192 $onserver = $_REQUEST['onserver'];
194 // Will we save dump on server?
195 $save_on_server = ! empty($cfg['SaveDir']) && $onserver;
199 // Does export require to be into file?
200 if ($export_plugin->getProperties()->getForceFile() != null && ! $asfile) {
201 $message = PMA_Message
::error(
202 __('Selected export type has to be saved in file!')
204 if ($export_type == 'server') {
205 $active_page = 'server_export.php';
206 include 'server_export.php';
207 } elseif ($export_type == 'database') {
208 $active_page = 'db_export.php';
209 include 'db_export.php';
211 $active_page = 'tbl_export.php';
212 include 'tbl_export.php';
217 // Generate error url and check for needed variables
218 if ($export_type == 'server') {
219 $err_url = 'server_export.php?' . PMA_generate_common_url();
220 } elseif ($export_type == 'database' && strlen($db)) {
221 $err_url = 'db_export.php?' . PMA_generate_common_url($db);
222 // Check if we have something to export
223 if (isset($table_select)) {
224 $tables = $table_select;
228 } elseif ($export_type == 'table' && strlen($db) && strlen($table)) {
229 $err_url = 'tbl_export.php?' . PMA_generate_common_url($db, $table);
231 PMA_fatalError(__('Bad parameters!'));
235 * Increase time limit for script execution and initializes some variables
237 @set_time_limit
($cfg['ExecTimeLimit']);
238 if (! empty($cfg['MemoryLimit'])) {
239 @ini_set
('memory_limit', $cfg['MemoryLimit']);
242 // Start with empty buffer
244 $dump_buffer_len = 0;
246 // We send fake headers to avoid browser timeout when buffering
247 $time_start = time();
251 * Detect ob_gzhandler
255 function PMA_isGzHandlerEnabled()
257 return in_array('ob_gzhandler', ob_list_handlers());
261 * Detect whether gzencode is needed; it might not be needed if
262 * the server is already compressing by itself
264 * @return bool Whether gzencode is needed
266 function PMA_gzencodeNeeded()
268 if (@function_exists
('gzencode')
269 && ! @ini_get
('zlib.output_compression')
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 && ! (function_exists('apache_get_modules')
274 && in_array('mod_deflate', apache_get_modules()))
275 && ! PMA_isGzHandlerEnabled()
284 * Output handler for all exports, if needed buffering, it stores data into
285 * $dump_buffer, otherwise it prints thems out.
287 * @param string $line the insert statement
289 * @return bool Whether output succeeded
291 function PMA_exportOutputHandler($line)
293 global $time_start, $dump_buffer, $dump_buffer_len, $save_filename;
295 // Kanji encoding convert feature
296 if ($GLOBALS['output_kanji_conversion']) {
297 $line = PMA_kanji_str_conv(
300 isset($GLOBALS['xkana']) ?
$GLOBALS['xkana'] : ''
303 // If we have to buffer data, we will perform everything at once at the end
304 if ($GLOBALS['buffer_needed']) {
306 $dump_buffer .= $line;
307 if ($GLOBALS['onfly_compression']) {
309 $dump_buffer_len +
= strlen($line);
311 if ($dump_buffer_len > $GLOBALS['memory_limit']) {
312 if ($GLOBALS['output_charset_conversion']) {
313 $dump_buffer = PMA_convert_string(
315 $GLOBALS['charset_of_file'],
320 if ($GLOBALS['compression'] == 'bzip2'
321 && @function_exists
('bzcompress')
323 $dump_buffer = bzcompress($dump_buffer);
324 } elseif ($GLOBALS['compression'] == 'gzip'
325 && PMA_gzencodeNeeded()
328 // without the optional parameter level because it bugs
329 $dump_buffer = gzencode($dump_buffer);
331 if ($GLOBALS['save_on_server']) {
332 $write_result = @fwrite
($GLOBALS['file_handle'], $dump_buffer);
333 if (! $write_result ||
($write_result != strlen($dump_buffer))) {
334 $GLOBALS['message'] = PMA_Message
::error(
335 __('Insufficient space to save the file %s.')
337 $GLOBALS['message']->addParam($save_filename);
344 $dump_buffer_len = 0;
348 if ($time_start >= $time_now +
30) {
349 $time_start = $time_now;
350 header('X-pmaPing: Pong');
354 if ($GLOBALS['asfile']) {
355 if ($GLOBALS['output_charset_conversion']) {
356 $line = PMA_convert_string(
358 $GLOBALS['charset_of_file'],
362 if ($GLOBALS['save_on_server'] && strlen($line) > 0) {
363 $write_result = @fwrite
($GLOBALS['file_handle'], $line);
364 if (! $write_result ||
($write_result != strlen($line))) {
365 $GLOBALS['message'] = PMA_Message
::error(
366 __('Insufficient space to save the file %s.')
368 $GLOBALS['message']->addParam($save_filename);
372 if ($time_start >= $time_now +
30) {
373 $time_start = $time_now;
374 header('X-pmaPing: Pong');
377 // We export as file - output normally
381 // We export as html - replace special chars
382 echo htmlspecialchars($line);
386 } // end of the 'PMA_exportOutputHandler()' function
388 // Defines the default <CR><LF> format.
389 // For SQL always use \n as MySQL wants this on all platforms.
390 if ($what == 'sql') {
393 $crlf = PMA_Util
::whichCrlf();
396 $output_kanji_conversion = function_exists('PMA_kanji_str_conv') && $type != 'xls';
398 // Do we need to convert charset?
399 $output_charset_conversion = $asfile
400 && $GLOBALS['PMA_recoding_engine'] != PMA_CHARSET_NONE
401 && isset($charset_of_file) && $charset_of_file != 'utf-8'
404 // Use on the fly compression?
405 $onfly_compression = $GLOBALS['cfg']['CompressOnFly']
406 && ($compression == 'gzip' ||
$compression == 'bzip2');
407 if ($onfly_compression) {
408 $memory_limit = trim(@ini_get
('memory_limit'));
410 if (empty($memory_limit)) {
411 $memory_limit = 2 * 1024 * 1024;
414 if (strtolower(substr($memory_limit, -1)) == 'm') {
415 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024;
416 } elseif (strtolower(substr($memory_limit, -1)) == 'k') {
417 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024;
418 } elseif (strtolower(substr($memory_limit, -1)) == 'g') {
419 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024 * 1024;
421 $memory_limit = (int)$memory_limit;
424 // Some of memory is needed for other thins and as treshold.
425 // Nijel: During export I had allocated (see memory_get_usage function)
426 // approx 1.2MB so this comes from that.
427 if ($memory_limit > 1500000) {
428 $memory_limit -= 1500000;
431 // Some memory is needed for compression, assume 1/3
435 // Generate filename and mime type if needed
437 $pma_uri_parts = parse_url($cfg['PmaAbsoluteUri']);
438 if ($export_type == 'server') {
439 if (isset($remember_template)) {
440 $GLOBALS['PMA_Config']->setUserValue(
441 'pma_server_filename_template',
442 'Export/file_template_server',
446 } elseif ($export_type == 'database') {
447 if (isset($remember_template)) {
448 $GLOBALS['PMA_Config']->setUserValue(
449 'pma_db_filename_template',
450 'Export/file_template_database',
455 if (isset($remember_template)) {
456 $GLOBALS['PMA_Config']->setUserValue(
457 'pma_table_filename_template',
458 'Export/file_template_table',
463 $filename = PMA_Util
::expandUserString($filename_template);
464 // remove dots in filename (coming from either the template or already
465 // part of the filename) to avoid a remote code execution vulnerability
466 $filename = PMA_sanitizeFilename($filename, $replaceDots = true);
468 // Grab basic dump extension and mime type
469 // Check if the user already added extension;
470 // get the substring where the extension would be if it was included
471 $extension_start_pos = strlen($filename) - strlen(
472 $export_plugin->getProperties()->getExtension()
474 $user_extension = substr($filename, $extension_start_pos, strlen($filename));
475 $required_extension = "." . $export_plugin->getProperties()->getExtension();
476 if (strtolower($user_extension) != $required_extension) {
477 $filename .= $required_extension;
479 $mime_type = $export_plugin->getProperties()->getMimeType();
481 // If dump is going to be compressed, set correct mime_type and add
482 // compression to extension
483 if ($compression == 'bzip2') {
485 $mime_type = 'application/x-bzip2';
486 } elseif ($compression == 'gzip') {
488 $mime_type = 'application/x-gzip';
489 } elseif ($compression == 'zip') {
491 $mime_type = 'application/zip';
495 // Open file on server if needed
496 if ($save_on_server) {
497 $save_filename = PMA_Util
::userDir($cfg['SaveDir'])
498 . preg_replace('@[/\\\\]@', '_', $filename);
500 if (file_exists($save_filename)
501 && ((! $quick_export && empty($onserverover))
503 && $_REQUEST['quick_export_onserverover'] != 'saveitover'))
505 $message = PMA_Message
::error(
506 __('File %s already exists on server, change filename or check overwrite option.')
508 $message->addParam($save_filename);
510 if (is_file($save_filename) && ! is_writable($save_filename)) {
511 $message = PMA_Message
::error(
512 __('The web server does not have permission to save the file %s.')
514 $message->addParam($save_filename);
516 if (! $file_handle = @fopen
($save_filename, 'w')) {
517 $message = PMA_Message
::error(
518 __('The web server does not have permission to save the file %s.')
520 $message->addParam($save_filename);
524 if (isset($message)) {
525 if ($export_type == 'server') {
526 $active_page = 'server_export.php';
527 include 'server_export.php';
528 } elseif ($export_type == 'database') {
529 $active_page = 'db_export.php';
530 include 'db_export.php';
532 $active_page = 'tbl_export.php';
533 include 'tbl_export.php';
540 * Send headers depending on whether the user chose to download a dump file
543 if (! $save_on_server) {
546 // (avoid rewriting data containing HTML with anchors and forms;
547 // this was reported to happen under Plesk)
548 @ini_set
('url_rewriter.tags', '');
549 $filename = PMA_sanitizeFilename($filename);
551 PMA_downloadHeader($filename, $mime_type);
554 if ($export_type == 'database') {
555 $num_tables = count($tables);
556 if ($num_tables == 0) {
557 $message = PMA_Message
::error(__('No tables found in database.'));
558 $active_page = 'db_export.php';
559 include 'db_export.php';
563 $backup_cfgServer = $cfg['Server'];
564 $cfg['Server'] = $backup_cfgServer;
565 unset($backup_cfgServer);
566 echo "\n" . '<div style="text-align: ' . $cell_align_left . '">' . "\n";
567 //echo ' <pre>' . "\n";
570 * Displays a back button with all the $_REQUEST data in the URL
571 * (store in a variable to also display after the textarea)
573 $back_button = '<p>[ <a href="';
574 if ($export_type == 'server') {
575 $back_button .= 'server_export.php?' . PMA_generate_common_url();
576 } elseif ($export_type == 'database') {
577 $back_button .= 'db_export.php?' . PMA_generate_common_url($db);
579 $back_button .= 'tbl_export.php?' . PMA_generate_common_url($db, $table);
582 // Convert the multiple select elements from an array to a string
583 if ($export_type == 'server' && isset($_REQUEST['db_select'])) {
584 $_REQUEST['db_select'] = implode(",", $_REQUEST['db_select']);
585 } elseif ($export_type == 'database' && isset($_REQUEST['table_select'])) {
586 $_REQUEST['table_select'] = implode(",", $_REQUEST['table_select']);
589 foreach ($_REQUEST as $name => $value) {
590 $back_button .= '&' . urlencode($name) . '=' . urlencode($value);
592 $back_button .= '&repopulate=1">Back</a> ]</p>';
595 echo ' <form name="nofunction">' . "\n"
596 // remove auto-select for now: there is no way to select
597 // only a part of the text; anyway, it should obey
598 // $cfg['TextareaAutoSelect']
599 //. ' <textarea name="sqldump" cols="50" rows="30" onclick="this.select();" id="textSQLDUMP" wrap="OFF">' . "\n";
600 . ' <textarea name="sqldump" cols="50" rows="30" id="textSQLDUMP" wrap="OFF">' . "\n";
604 // Fake loop just to allow skip of remain of this code by break, I'd really
605 // need exceptions here :-)
608 // Add possibly some comments to export
609 if (! $export_plugin->exportHeader($db)) {
613 // Will we need relation & co. setup?
614 $do_relation = isset($GLOBALS[$what . '_relation']);
615 $do_comments = isset($GLOBALS[$what . '_include_comments']);
616 $do_mime = isset($GLOBALS[$what . '_mime']);
617 if ($do_relation ||
$do_comments ||
$do_mime) {
618 $cfgRelation = PMA_getRelationsParam();
621 include_once 'libraries/transformations.lib.php';
624 // Include dates in export?
625 $do_dates = isset($GLOBALS[$what . '_dates']);
630 // Gets the number of tables if a dump of a database has been required
631 if ($export_type == 'server') {
632 if (isset($db_select)) {
633 $tmp_select = implode($db_select, '|');
634 $tmp_select = '|' . $tmp_select . '|';
636 // Walk over databases
637 foreach ($GLOBALS['pma']->databases
as $current_db) {
638 if (isset($tmp_select)
639 && strpos(' ' . $tmp_select, '|' . $current_db . '|')
641 if (! $export_plugin->exportDBHeader($current_db)) {
644 if (! $export_plugin->exportDBCreate($current_db)) {
647 if (method_exists($export_plugin, 'exportRoutines')
648 && strpos($GLOBALS['sql_structure_or_data'], 'structure') !== false
649 && isset($GLOBALS['sql_procedure_function'])
651 $export_plugin->exportRoutines($current_db);
654 $tables = PMA_DBI_get_tables($current_db);
656 foreach ($tables as $table) {
657 // if this is a view, collect it for later;
658 // views must be exported after the tables
659 $is_view = PMA_Table
::isView($current_db, $table);
663 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
664 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
666 // for a view, export a stand-in definition of the table
667 // to resolve view dependencies
668 if (! $export_plugin->exportStructure(
669 $current_db, $table, $crlf, $err_url,
670 $is_view ?
'stand_in' : 'create_table', $export_type,
671 $do_relation, $do_comments, $do_mime, $do_dates
676 // if this is a view or a merge table, don't export data
677 if (($GLOBALS[$what . '_structure_or_data'] == 'data'
678 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data')
679 && ! ($is_view || PMA_Table
::isMerge($current_db, $table))
681 $local_query = 'SELECT * FROM ' . PMA_Util
::backquote($current_db)
682 . '.' . PMA_Util
::backquote($table);
683 if (! $export_plugin->exportData($current_db, $table, $crlf, $err_url, $local_query)) {
687 // now export the triggers (needs to be done after the data
688 // because triggers can modify already imported tables)
689 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
690 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
692 if (! $export_plugin->exportStructure(
693 $current_db, $table, $crlf, $err_url,
694 'triggers', $export_type,
695 $do_relation, $do_comments, $do_mime, $do_dates
701 foreach ($views as $view) {
702 // no data export for a view
703 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
704 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
706 if (! $export_plugin->exportStructure(
707 $current_db, $view, $crlf, $err_url,
708 'create_view', $export_type,
709 $do_relation, $do_comments, $do_mime, $do_dates
715 if (! $export_plugin->exportDBFooter($current_db)) {
720 } elseif ($export_type == 'database') {
721 if (! $export_plugin->exportDBHeader($db)) {
724 if (! $export_plugin->exportDBCreate($db)) {
728 if (method_exists($export_plugin, 'exportRoutines')
729 && strpos($GLOBALS['sql_structure_or_data'], 'structure') !== false
730 && isset($GLOBALS['sql_procedure_function'])
732 $export_plugin->exportRoutines($db);
737 // $tables contains the choices from the user (via $table_select)
738 foreach ($tables as $table) {
739 // if this is a view, collect it for later; views must be exported after
741 $is_view = PMA_Table
::isView($db, $table);
745 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
746 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
748 // for a view, export a stand-in definition of the table
749 // to resolve view dependencies
750 if (! $export_plugin->exportStructure(
751 $db, $table, $crlf, $err_url,
752 $is_view ?
'stand_in' : 'create_table', $export_type,
753 $do_relation, $do_comments, $do_mime, $do_dates
758 // if this is a view or a merge table, don't export data
759 if (($GLOBALS[$what . '_structure_or_data'] == 'data'
760 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data')
761 && ! ($is_view || PMA_Table
::isMerge($db, $table))
763 $local_query = 'SELECT * FROM ' . PMA_Util
::backquote($db)
764 . '.' . PMA_Util
::backquote($table);
765 if (! $export_plugin->exportData($db, $table, $crlf, $err_url, $local_query)) {
769 // now export the triggers (needs to be done after the data because
770 // triggers can modify already imported tables)
771 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
772 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
774 if (! $export_plugin->exportStructure(
775 $db, $table, $crlf, $err_url,
776 'triggers', $export_type,
777 $do_relation, $do_comments, $do_mime, $do_dates
783 foreach ($views as $view) {
784 // no data export for a view
785 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
786 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
788 if (! $export_plugin->exportStructure(
789 $db, $view, $crlf, $err_url,
790 'create_view', $export_type,
791 $do_relation, $do_comments, $do_mime, $do_dates
798 if (! $export_plugin->exportDBFooter($db)) {
802 if (! $export_plugin->exportDBHeader($db)) {
805 // We export just one table
806 // $allrows comes from the form when "Dump all rows" has been selected
807 if (isset($allrows) && $allrows == '0' && $limit_to > 0 && $limit_from >= 0) {
808 $add_query = ' LIMIT '
809 . (($limit_from > 0) ?
$limit_from . ', ' : '')
815 $is_view = PMA_Table
::isView($db, $table);
816 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
817 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
819 if (! $export_plugin->exportStructure(
820 $db, $table, $crlf, $err_url,
821 $is_view ?
'create_view' : 'create_table', $export_type,
822 $do_relation, $do_comments, $do_mime, $do_dates
827 // If this is an export of a single view, we have to export data;
828 // for example, a PDF report
829 // if it is a merge table, no data is exported
830 if (($GLOBALS[$what . '_structure_or_data'] == 'data'
831 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data')
832 && ! PMA_Table
::isMerge($db, $table)
834 if (! empty($sql_query)) {
835 // only preg_replace if needed
836 if (! empty($add_query)) {
837 // remove trailing semicolon before adding a LIMIT
838 $sql_query = preg_replace('%;\s*$%', '', $sql_query);
840 $local_query = $sql_query . $add_query;
841 PMA_DBI_select_db($db);
843 $local_query = 'SELECT * FROM ' . PMA_Util
::backquote($db)
844 . '.' . PMA_Util
::backquote($table) . $add_query;
846 if (! $export_plugin->exportData($db, $table, $crlf, $err_url, $local_query)) {
850 // now export the triggers (needs to be done after the data because
851 // triggers can modify already imported tables)
852 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
853 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
855 if (! $export_plugin->exportStructure(
856 $db, $table, $crlf, $err_url,
857 'triggers', $export_type,
858 $do_relation, $do_comments, $do_mime, $do_dates
863 if (! $export_plugin->exportDBFooter($db)) {
867 if (! $export_plugin->exportFooter()) {
874 if ($save_on_server && isset($message)) {
875 if ($export_type == 'server') {
876 $active_page = 'server_export.php';
877 include 'server_export.php';
878 } elseif ($export_type == 'database') {
879 $active_page = 'db_export.php';
880 include 'db_export.php';
882 $active_page = 'tbl_export.php';
883 include 'tbl_export.php';
889 * Send the dump as a file...
891 if (! empty($asfile)) {
892 // Convert the charset if required.
893 if ($output_charset_conversion) {
894 $dump_buffer = PMA_convert_string(
896 $GLOBALS['charset_of_file'],
901 // Do the compression
902 // 1. as a zipped file
903 if ($compression == 'zip') {
904 if (@function_exists
('gzcompress')) {
905 $zipfile = new ZipFile();
906 $zipfile->addFile($dump_buffer, substr($filename, 0, -4));
907 $dump_buffer = $zipfile->file();
909 } elseif ($compression == 'bzip2') {
910 // 2. as a bzipped file
911 if (@function_exists
('bzcompress')) {
912 $dump_buffer = bzcompress($dump_buffer);
914 } elseif ($compression == 'gzip' && PMA_gzencodeNeeded()) {
915 // 3. as a gzipped file
916 // without the optional parameter level because it bugs
917 $dump_buffer = gzencode($dump_buffer);
920 /* If we saved on server, we have to close file now */
921 if ($save_on_server) {
922 $write_result = @fwrite
($file_handle, $dump_buffer);
923 fclose($file_handle);
924 if (strlen($dump_buffer) > 0
925 && (! $write_result ||
($write_result != strlen($dump_buffer)))
927 $message = new PMA_Message(
928 __('Insufficient space to save the file %s.'),
933 $message = new PMA_Message(
934 __('Dump has been saved to file %s.'),
935 PMA_Message
::SUCCESS
,
940 if ($export_type == 'server') {
941 $active_page = 'server_export.php';
942 include_once 'server_export.php';
943 } elseif ($export_type == 'database') {
944 $active_page = 'db_export.php';
945 include_once 'db_export.php';
947 $active_page = 'tbl_export.php';
948 include_once 'tbl_export.php';
952 PMA_Response
::getInstance()->disable();
957 * Displays the dump...
959 * Close the html tags and add the footers if dump is displayed on screen
961 echo '</textarea>' . "\n"
966 echo '</div>' . "\n";
969 <script type
="text/javascript">
971 var $body = $
("body");
973 .width($body.width() - 50)
974 .height($body.height() - 100);