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',
107 'latex_structure_or_data',
108 'latex_structure_caption',
109 'latex_structure_continued_caption',
110 'latex_structure_label',
115 'latex_data_caption',
116 'latex_data_continued_caption',
121 foreach ($post_params as $one_post_param) {
122 if (isset($_POST[$one_post_param])) {
123 $GLOBALS[$one_post_param] = $_POST[$one_post_param];
127 // sanitize this parameter which will be used below in a file inclusion
128 $what = PMA_securePath($what);
130 PMA_Util
::checkParameters(array('what', 'export_type'));
132 // export class instance, not array of properties, as before
133 $export_plugin = PMA_getPlugin(
136 'libraries/plugins/export/',
138 'export_type' => $export_type,
139 'single_table' => isset($single_table)
143 // Backward compatbility
147 if (! isset($export_plugin)) {
148 PMA_fatalError(__('Bad type!'));
152 * valid compression methods
154 $compression_methods = array(
161 * init and variable checking
163 $compression = false;
165 $save_on_server = false;
166 $buffer_needed = false;
168 // Is it a quick or custom export?
169 if ($_REQUEST['quick_or_custom'] == 'quick') {
170 $quick_export = true;
172 $quick_export = false;
175 if ($_REQUEST['output_format'] == 'astext') {
179 if (in_array($_REQUEST['compression'], $compression_methods)) {
180 $compression = $_REQUEST['compression'];
181 $buffer_needed = true;
183 if (($quick_export && ! empty($_REQUEST['quick_export_onserver']))
184 ||
(! $quick_export && ! empty($_REQUEST['onserver']))
187 $onserver = $_REQUEST['quick_export_onserver'];
189 $onserver = $_REQUEST['onserver'];
191 // Will we save dump on server?
192 $save_on_server = ! empty($cfg['SaveDir']) && $onserver;
196 // Does export require to be into file?
197 if ($export_plugin->getProperties()->getForceFile() != null && ! $asfile) {
198 $message = PMA_Message
::error(
199 __('Selected export type has to be saved in file!')
201 if ($export_type == 'server') {
202 $active_page = 'server_export.php';
203 include 'server_export.php';
204 } elseif ($export_type == 'database') {
205 $active_page = 'db_export.php';
206 include 'db_export.php';
208 $active_page = 'tbl_export.php';
209 include 'tbl_export.php';
214 // Generate error url and check for needed variables
215 if ($export_type == 'server') {
216 $err_url = 'server_export.php?' . PMA_generate_common_url();
217 } elseif ($export_type == 'database' && strlen($db)) {
218 $err_url = 'db_export.php?' . PMA_generate_common_url($db);
219 // Check if we have something to export
220 if (isset($table_select)) {
221 $tables = $table_select;
225 } elseif ($export_type == 'table' && strlen($db) && strlen($table)) {
226 $err_url = 'tbl_export.php?' . PMA_generate_common_url($db, $table);
228 PMA_fatalError(__('Bad parameters!'));
232 * Increase time limit for script execution and initializes some variables
234 @set_time_limit
($cfg['ExecTimeLimit']);
235 if (! empty($cfg['MemoryLimit'])) {
236 @ini_set
('memory_limit', $cfg['MemoryLimit']);
239 // Start with empty buffer
241 $dump_buffer_len = 0;
243 // We send fake headers to avoid browser timeout when buffering
244 $time_start = time();
248 * Detect ob_gzhandler
252 function PMA_isGzHandlerEnabled()
254 return in_array('ob_gzhandler', ob_list_handlers());
258 * Detect whether gzencode is needed; it might not be needed if
259 * the server is already compressing by itself
261 * @return bool Whether gzencode is needed
263 function PMA_gzencodeNeeded()
265 // Here, we detect Apache's mod_deflate so we bet that
266 // this module is active for this instance of phpMyAdmin
267 // and therefore, will gzip encode the content
268 if (@function_exists
('gzencode')
269 && ! @ini_get
('zlib.output_compression')
270 && ! (function_exists('apache_get_modules')
271 && in_array('mod_deflate', apache_get_modules()))
272 && ! PMA_isGzHandlerEnabled()
281 * Output handler for all exports, if needed buffering, it stores data into
282 * $dump_buffer, otherwise it prints thems out.
284 * @param string $line the insert statement
286 * @return bool Whether output succeeded
288 function PMA_exportOutputHandler($line)
290 global $time_start, $dump_buffer, $dump_buffer_len, $save_filename;
292 // Kanji encoding convert feature
293 if ($GLOBALS['output_kanji_conversion']) {
294 $line = PMA_kanji_str_conv(
297 isset($GLOBALS['xkana']) ?
$GLOBALS['xkana'] : ''
300 // If we have to buffer data, we will perform everything at once at the end
301 if ($GLOBALS['buffer_needed']) {
303 $dump_buffer .= $line;
304 if ($GLOBALS['onfly_compression']) {
306 $dump_buffer_len +
= strlen($line);
308 if ($dump_buffer_len > $GLOBALS['memory_limit']) {
309 if ($GLOBALS['output_charset_conversion']) {
310 $dump_buffer = PMA_convertString(
312 $GLOBALS['charset_of_file'],
317 if ($GLOBALS['compression'] == 'bzip2'
318 && @function_exists
('bzcompress')
320 $dump_buffer = bzcompress($dump_buffer);
321 } elseif ($GLOBALS['compression'] == 'gzip'
322 && PMA_gzencodeNeeded()
325 // without the optional parameter level because it bugs
326 $dump_buffer = gzencode($dump_buffer);
328 if ($GLOBALS['save_on_server']) {
329 $write_result = @fwrite
($GLOBALS['file_handle'], $dump_buffer);
330 if (! $write_result ||
($write_result != strlen($dump_buffer))) {
331 $GLOBALS['message'] = PMA_Message
::error(
332 __('Insufficient space to save the file %s.')
334 $GLOBALS['message']->addParam($save_filename);
341 $dump_buffer_len = 0;
345 if ($time_start >= $time_now +
30) {
346 $time_start = $time_now;
347 header('X-pmaPing: Pong');
351 if ($GLOBALS['asfile']) {
352 if ($GLOBALS['output_charset_conversion']) {
353 $line = PMA_convertString(
355 $GLOBALS['charset_of_file'],
359 if ($GLOBALS['save_on_server'] && strlen($line) > 0) {
360 $write_result = @fwrite
($GLOBALS['file_handle'], $line);
361 if (! $write_result ||
($write_result != strlen($line))) {
362 $GLOBALS['message'] = PMA_Message
::error(
363 __('Insufficient space to save the file %s.')
365 $GLOBALS['message']->addParam($save_filename);
369 if ($time_start >= $time_now +
30) {
370 $time_start = $time_now;
371 header('X-pmaPing: Pong');
374 // We export as file - output normally
378 // We export as html - replace special chars
379 echo htmlspecialchars($line);
383 } // end of the 'PMA_exportOutputHandler()' function
385 // Defines the default <CR><LF> format.
386 // For SQL always use \n as MySQL wants this on all platforms.
387 if ($what == 'sql') {
390 $crlf = PMA_Util
::whichCrlf();
393 $output_kanji_conversion = function_exists('PMA_kanji_str_conv') && $type != 'xls';
395 // Do we need to convert charset?
396 $output_charset_conversion = $asfile
397 && $GLOBALS['PMA_recoding_engine'] != PMA_CHARSET_NONE
398 && isset($charset_of_file) && $charset_of_file != 'utf-8'
401 // Use on the fly compression?
402 $onfly_compression = $GLOBALS['cfg']['CompressOnFly']
403 && ($compression == 'gzip' ||
$compression == 'bzip2');
404 if ($onfly_compression) {
405 $memory_limit = trim(@ini_get
('memory_limit'));
407 if (empty($memory_limit)) {
408 $memory_limit = 2 * 1024 * 1024;
411 if (strtolower(substr($memory_limit, -1)) == 'm') {
412 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024;
413 } elseif (strtolower(substr($memory_limit, -1)) == 'k') {
414 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024;
415 } elseif (strtolower(substr($memory_limit, -1)) == 'g') {
416 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024 * 1024;
418 $memory_limit = (int)$memory_limit;
421 // Some of memory is needed for other thins and as treshold.
422 // Nijel: During export I had allocated (see memory_get_usage function)
423 // approx 1.2MB so this comes from that.
424 if ($memory_limit > 1500000) {
425 $memory_limit -= 1500000;
428 // Some memory is needed for compression, assume 1/3
432 // Generate filename and mime type if needed
434 $pma_uri_parts = parse_url($cfg['PmaAbsoluteUri']);
435 if ($export_type == 'server') {
436 if (isset($remember_template)) {
437 $GLOBALS['PMA_Config']->setUserValue(
438 'pma_server_filename_template',
439 'Export/file_template_server',
443 } elseif ($export_type == 'database') {
444 if (isset($remember_template)) {
445 $GLOBALS['PMA_Config']->setUserValue(
446 'pma_db_filename_template',
447 'Export/file_template_database',
452 if (isset($remember_template)) {
453 $GLOBALS['PMA_Config']->setUserValue(
454 'pma_table_filename_template',
455 'Export/file_template_table',
460 $filename = PMA_Util
::expandUserString($filename_template);
461 // remove dots in filename (coming from either the template or already
462 // part of the filename) to avoid a remote code execution vulnerability
463 $filename = PMA_sanitizeFilename($filename, $replaceDots = true);
465 // Grab basic dump extension and mime type
466 // Check if the user already added extension;
467 // get the substring where the extension would be if it was included
468 $extension_start_pos = strlen($filename) - strlen(
469 $export_plugin->getProperties()->getExtension()
471 $user_extension = substr($filename, $extension_start_pos, strlen($filename));
472 $required_extension = "." . $export_plugin->getProperties()->getExtension();
473 if (strtolower($user_extension) != $required_extension) {
474 $filename .= $required_extension;
476 $mime_type = $export_plugin->getProperties()->getMimeType();
478 // If dump is going to be compressed, set correct mime_type and add
479 // compression to extension
480 if ($compression == 'bzip2') {
482 $mime_type = 'application/x-bzip2';
483 } elseif ($compression == 'gzip') {
485 $mime_type = 'application/x-gzip';
486 } elseif ($compression == 'zip') {
488 $mime_type = 'application/zip';
492 // Open file on server if needed
493 if ($save_on_server) {
494 $save_filename = PMA_Util
::userDir($cfg['SaveDir'])
495 . preg_replace('@[/\\\\]@', '_', $filename);
497 if (file_exists($save_filename)
498 && ((! $quick_export && empty($onserverover))
500 && $_REQUEST['quick_export_onserverover'] != 'saveitover'))
502 $message = PMA_Message
::error(
503 __('File %s already exists on server, change filename or check overwrite option.')
505 $message->addParam($save_filename);
507 if (is_file($save_filename) && ! is_writable($save_filename)) {
508 $message = PMA_Message
::error(
509 __('The web server does not have permission to save the file %s.')
511 $message->addParam($save_filename);
513 if (! $file_handle = @fopen
($save_filename, 'w')) {
514 $message = PMA_Message
::error(
515 __('The web server does not have permission to save the file %s.')
517 $message->addParam($save_filename);
521 if (isset($message)) {
522 if ($export_type == 'server') {
523 $active_page = 'server_export.php';
524 include 'server_export.php';
525 } elseif ($export_type == 'database') {
526 $active_page = 'db_export.php';
527 include 'db_export.php';
529 $active_page = 'tbl_export.php';
530 include 'tbl_export.php';
537 * Send headers depending on whether the user chose to download a dump file
540 if (! $save_on_server) {
543 // (avoid rewriting data containing HTML with anchors and forms;
544 // this was reported to happen under Plesk)
545 @ini_set
('url_rewriter.tags', '');
546 $filename = PMA_sanitizeFilename($filename);
548 PMA_downloadHeader($filename, $mime_type);
551 if ($export_type == 'database') {
552 $num_tables = count($tables);
553 if ($num_tables == 0) {
554 $message = PMA_Message
::error(__('No tables found in database.'));
555 $active_page = 'db_export.php';
556 include 'db_export.php';
560 $backup_cfgServer = $cfg['Server'];
561 $cfg['Server'] = $backup_cfgServer;
562 unset($backup_cfgServer);
563 echo "\n" . '<div style="text-align: ' . $cell_align_left . '">' . "\n";
564 //echo ' <pre>' . "\n";
567 * Displays a back button with all the $_REQUEST data in the URL
568 * (store in a variable to also display after the textarea)
570 $back_button = '<p>[ <a href="';
571 if ($export_type == 'server') {
572 $back_button .= 'server_export.php?' . PMA_generate_common_url();
573 } elseif ($export_type == 'database') {
574 $back_button .= 'db_export.php?' . PMA_generate_common_url($db);
576 $back_button .= 'tbl_export.php?' . PMA_generate_common_url($db, $table);
579 // Convert the multiple select elements from an array to a string
580 if ($export_type == 'server' && isset($_REQUEST['db_select'])) {
581 $_REQUEST['db_select'] = implode(",", $_REQUEST['db_select']);
582 } elseif ($export_type == 'database' && isset($_REQUEST['table_select'])) {
583 $_REQUEST['table_select'] = implode(",", $_REQUEST['table_select']);
586 foreach ($_REQUEST as $name => $value) {
587 $back_button .= '&' . urlencode($name) . '=' . urlencode($value);
589 $back_button .= '&repopulate=1">Back</a> ]</p>';
592 echo ' <form name="nofunction">' . "\n"
593 // remove auto-select for now: there is no way to select
594 // only a part of the text; anyway, it should obey
595 // $cfg['TextareaAutoSelect']
596 //. ' <textarea name="sqldump" cols="50" rows="30" onclick="this.select();" id="textSQLDUMP" wrap="OFF">' . "\n";
597 . ' <textarea name="sqldump" cols="50" rows="30" id="textSQLDUMP" wrap="OFF">' . "\n";
601 // Fake loop just to allow skip of remain of this code by break, I'd really
602 // need exceptions here :-)
605 // Add possibly some comments to export
606 if (! $export_plugin->exportHeader($db)) {
610 // Will we need relation & co. setup?
611 $do_relation = isset($GLOBALS[$what . '_relation']);
612 $do_comments = isset($GLOBALS[$what . '_include_comments']);
613 $do_mime = isset($GLOBALS[$what . '_mime']);
614 if ($do_relation ||
$do_comments ||
$do_mime) {
615 $cfgRelation = PMA_getRelationsParam();
618 include_once 'libraries/transformations.lib.php';
621 // Include dates in export?
622 $do_dates = isset($GLOBALS[$what . '_dates']);
627 // Gets the number of tables if a dump of a database has been required
628 if ($export_type == 'server') {
629 if (isset($db_select)) {
630 $tmp_select = implode($db_select, '|');
631 $tmp_select = '|' . $tmp_select . '|';
633 // Walk over databases
634 foreach ($GLOBALS['pma']->databases
as $current_db) {
635 if ((isset($tmp_select)
636 && strpos(' ' . $tmp_select, '|' . $current_db . '|'))
637 ||
! isset($tmp_select)
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_getTables($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)) {
723 if (method_exists($export_plugin, 'exportRoutines')
724 && strpos($GLOBALS['sql_structure_or_data'], 'structure') !== false
725 && isset($GLOBALS['sql_procedure_function'])
727 $export_plugin->exportRoutines($db);
732 // $tables contains the choices from the user (via $table_select)
733 foreach ($tables as $table) {
734 // if this is a view, collect it for later; views must be exported after
736 $is_view = PMA_Table
::isView($db, $table);
740 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
741 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
743 // for a view, export a stand-in definition of the table
744 // to resolve view dependencies
745 if (! $export_plugin->exportStructure(
746 $db, $table, $crlf, $err_url,
747 $is_view ?
'stand_in' : 'create_table', $export_type,
748 $do_relation, $do_comments, $do_mime, $do_dates
753 // if this is a view or a merge table, don't export data
754 if (($GLOBALS[$what . '_structure_or_data'] == 'data'
755 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data')
756 && ! ($is_view || PMA_Table
::isMerge($db, $table))
758 $local_query = 'SELECT * FROM ' . PMA_Util
::backquote($db)
759 . '.' . PMA_Util
::backquote($table);
760 if (! $export_plugin->exportData($db, $table, $crlf, $err_url, $local_query)) {
764 // now export the triggers (needs to be done after the data because
765 // triggers can modify already imported tables)
766 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
767 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
769 if (! $export_plugin->exportStructure(
770 $db, $table, $crlf, $err_url,
771 'triggers', $export_type,
772 $do_relation, $do_comments, $do_mime, $do_dates
778 foreach ($views as $view) {
779 // no data export for a view
780 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
781 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
783 if (! $export_plugin->exportStructure(
784 $db, $view, $crlf, $err_url,
785 'create_view', $export_type,
786 $do_relation, $do_comments, $do_mime, $do_dates
793 if (! $export_plugin->exportDBFooter($db)) {
797 if (! $export_plugin->exportDBHeader($db)) {
800 // We export just one table
801 // $allrows comes from the form when "Dump all rows" has been selected
802 if (isset($allrows) && $allrows == '0' && $limit_to > 0 && $limit_from >= 0) {
803 $add_query = ' LIMIT '
804 . (($limit_from > 0) ?
$limit_from . ', ' : '')
810 $is_view = PMA_Table
::isView($db, $table);
811 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
812 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
814 if (! $export_plugin->exportStructure(
815 $db, $table, $crlf, $err_url,
816 $is_view ?
'create_view' : 'create_table', $export_type,
817 $do_relation, $do_comments, $do_mime, $do_dates
822 // If this is an export of a single view, we have to export data;
823 // for example, a PDF report
824 // if it is a merge table, no data is exported
825 if (($GLOBALS[$what . '_structure_or_data'] == 'data'
826 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data')
827 && ! PMA_Table
::isMerge($db, $table)
829 if (! empty($sql_query)) {
830 // only preg_replace if needed
831 if (! empty($add_query)) {
832 // remove trailing semicolon before adding a LIMIT
833 $sql_query = preg_replace('%;\s*$%', '', $sql_query);
835 $local_query = $sql_query . $add_query;
836 PMA_DBI_selectDb($db);
838 $local_query = 'SELECT * FROM ' . PMA_Util
::backquote($db)
839 . '.' . PMA_Util
::backquote($table) . $add_query;
841 if (! $export_plugin->exportData($db, $table, $crlf, $err_url, $local_query)) {
845 // now export the triggers (needs to be done after the data because
846 // triggers can modify already imported tables)
847 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
848 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
850 if (! $export_plugin->exportStructure(
851 $db, $table, $crlf, $err_url,
852 'triggers', $export_type,
853 $do_relation, $do_comments, $do_mime, $do_dates
858 if (! $export_plugin->exportDBFooter($db)) {
862 if (! $export_plugin->exportFooter()) {
869 if ($save_on_server && isset($message)) {
870 if ($export_type == 'server') {
871 $active_page = 'server_export.php';
872 include 'server_export.php';
873 } elseif ($export_type == 'database') {
874 $active_page = 'db_export.php';
875 include 'db_export.php';
877 $active_page = 'tbl_export.php';
878 include 'tbl_export.php';
884 * Send the dump as a file...
886 if (! empty($asfile)) {
887 // Convert the charset if required.
888 if ($output_charset_conversion) {
889 $dump_buffer = PMA_convertString(
891 $GLOBALS['charset_of_file'],
896 // Do the compression
897 // 1. as a zipped file
898 if ($compression == 'zip') {
899 if (@function_exists
('gzcompress')) {
900 $zipfile = new ZipFile();
901 $zipfile->addFile($dump_buffer, substr($filename, 0, -4));
902 $dump_buffer = $zipfile->file();
904 } elseif ($compression == 'bzip2') {
905 // 2. as a bzipped file
906 if (@function_exists
('bzcompress')) {
907 $dump_buffer = bzcompress($dump_buffer);
909 } elseif ($compression == 'gzip' && PMA_gzencodeNeeded()) {
910 // 3. as a gzipped file
911 // without the optional parameter level because it bugs
912 $dump_buffer = gzencode($dump_buffer);
915 /* If we saved on server, we have to close file now */
916 if ($save_on_server) {
917 $write_result = @fwrite
($file_handle, $dump_buffer);
918 fclose($file_handle);
919 if (strlen($dump_buffer) > 0
920 && (! $write_result ||
($write_result != strlen($dump_buffer)))
922 $message = new PMA_Message(
923 __('Insufficient space to save the file %s.'),
928 $message = new PMA_Message(
929 __('Dump has been saved to file %s.'),
930 PMA_Message
::SUCCESS
,
935 if ($export_type == 'server') {
936 $active_page = 'server_export.php';
937 include_once 'server_export.php';
938 } elseif ($export_type == 'database') {
939 $active_page = 'db_export.php';
940 include_once 'db_export.php';
942 $active_page = 'tbl_export.php';
943 include_once 'tbl_export.php';
947 PMA_Response
::getInstance()->disable();
952 * Displays the dump...
954 * Close the html tags and add the footers if dump is displayed on screen
956 echo '</textarea>' . "\n"
961 echo '</div>' . "\n";
964 <script type
="text/javascript">
966 var $body = $
("body");
968 .width($body.width() - 50)
969 .height($body.height() - 100);