2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Main export handling code
10 * If we are sending the export file (as opposed to just displaying it
11 * as text), we have to bypass the usual PMA_Response mechanism
13 if ($_POST['output_format'] == 'sendit') {
14 define('PMA_BYPASS_GET_INSTANCE', 1);
18 * Get the variables sent or posted to this script and a core script
20 require_once 'libraries/common.inc.php';
21 require_once 'libraries/zip.lib.php';
22 require_once 'libraries/plugin_interface.lib.php';
25 * Sets globals from $_POST
27 * - Please keep the parameters in order of their appearance in the form
28 * - Some of these parameters are not used, as the code below directly
29 * verifies from the superglobal $_POST or $_REQUEST
49 'htmlword_structure_or_data',
52 'mediawiki_structure_or_data',
55 'pdf_structure_or_data',
56 'odt_structure_or_data',
62 'codegen_structure_or_data',
68 'excel_structure_or_data',
69 'yaml_structure_or_data',
71 'ods_structure_or_data',
73 'json_structure_or_data',
74 'xml_structure_or_data',
75 'xml_export_functions',
76 'xml_export_procedures',
78 'xml_export_triggers',
80 'xml_export_contents',
81 'texytext_structure_or_data',
84 'phparray_structure_or_data',
85 'sql_include_comments',
90 'sql_use_transaction',
93 'sql_structure_or_data',
94 'sql_create_database',
96 'sql_procedure_function',
97 'sql_create_table_statements',
106 'sql_max_query_size',
116 'csv_structure_or_data',
117 // csv_replace should have been here but we use it directly from $_POST
119 'latex_structure_or_data',
120 'latex_structure_caption',
121 'latex_structure_continued_caption',
122 'latex_structure_label',
127 'latex_data_caption',
128 'latex_data_continued_caption',
133 foreach ($post_params as $one_post_param) {
134 if (isset($_POST[$one_post_param])) {
135 $GLOBALS[$one_post_param] = $_POST[$one_post_param];
139 // sanitize this parameter which will be used below in a file inclusion
140 $what = PMA_securePath($what);
142 PMA_Util
::checkParameters(array('what', 'export_type'));
144 // export class instance, not array of properties, as before
145 $export_plugin = PMA_getPlugin(
148 'libraries/plugins/export/',
150 'export_type' => $export_type,
151 'single_table' => isset($single_table)
155 // Backward compatbility
159 if (! isset($export_plugin)) {
160 PMA_fatalError(__('Bad type!'));
164 * valid compression methods
166 $compression_methods = array(
173 * init and variable checking
175 $compression = false;
177 $save_on_server = false;
178 $buffer_needed = false;
180 // Is it a quick or custom export?
181 if ($_REQUEST['quick_or_custom'] == 'quick') {
182 $quick_export = true;
184 $quick_export = false;
187 if ($_REQUEST['output_format'] == 'astext') {
191 if (in_array($_REQUEST['compression'], $compression_methods)) {
192 $compression = $_REQUEST['compression'];
193 $buffer_needed = true;
195 if (($quick_export && ! empty($_REQUEST['quick_export_onserver']))
196 ||
(! $quick_export && ! empty($_REQUEST['onserver']))
199 $onserver = $_REQUEST['quick_export_onserver'];
201 $onserver = $_REQUEST['onserver'];
203 // Will we save dump on server?
204 $save_on_server = ! empty($cfg['SaveDir']) && $onserver;
208 // Does export require to be into file?
209 if ($export_plugin->getProperties()->getForceFile() != null && ! $asfile) {
210 $message = PMA_Message
::error(
211 __('Selected export type has to be saved in file!')
213 if ($export_type == 'server') {
214 $active_page = 'server_export.php';
215 include 'server_export.php';
216 } elseif ($export_type == 'database') {
217 $active_page = 'db_export.php';
218 include 'db_export.php';
220 $active_page = 'tbl_export.php';
221 include 'tbl_export.php';
226 // Generate error url and check for needed variables
227 if ($export_type == 'server') {
228 $err_url = 'server_export.php?' . PMA_generate_common_url();
229 } elseif ($export_type == 'database' && strlen($db)) {
230 $err_url = 'db_export.php?' . PMA_generate_common_url($db);
231 // Check if we have something to export
232 if (isset($table_select)) {
233 $tables = $table_select;
237 } elseif ($export_type == 'table' && strlen($db) && strlen($table)) {
238 $err_url = 'tbl_export.php?' . PMA_generate_common_url($db, $table);
240 PMA_fatalError(__('Bad parameters!'));
244 * Increase time limit for script execution and initializes some variables
246 @set_time_limit
($cfg['ExecTimeLimit']);
247 if (! empty($cfg['MemoryLimit'])) {
248 @ini_set
('memory_limit', $cfg['MemoryLimit']);
251 // Start with empty buffer
253 $dump_buffer_len = 0;
255 // We send fake headers to avoid browser timeout when buffering
256 $time_start = time();
260 * Detect ob_gzhandler
264 function PMA_isGzHandlerEnabled()
266 return in_array('ob_gzhandler', ob_list_handlers());
270 * Detect whether gzencode is needed; it might not be needed if
271 * the server is already compressing by itself
273 * @return bool Whether gzencode is needed
275 function PMA_gzencodeNeeded()
277 if (@function_exists
('gzencode')
278 && ! @ini_get
('zlib.output_compression')
279 && ! PMA_isGzHandlerEnabled()
288 * Output handler for all exports, if needed buffering, it stores data into
289 * $dump_buffer, otherwise it prints thems out.
291 * @param string $line the insert statement
293 * @return bool Whether output succeeded
295 function PMA_exportOutputHandler($line)
297 global $time_start, $dump_buffer, $dump_buffer_len, $save_filename;
299 // Kanji encoding convert feature
300 if ($GLOBALS['output_kanji_conversion']) {
301 $line = PMA_kanji_str_conv(
304 isset($GLOBALS['xkana']) ?
$GLOBALS['xkana'] : ''
307 // If we have to buffer data, we will perform everything at once at the end
308 if ($GLOBALS['buffer_needed']) {
310 $dump_buffer .= $line;
311 if ($GLOBALS['onfly_compression']) {
313 $dump_buffer_len +
= strlen($line);
315 if ($dump_buffer_len > $GLOBALS['memory_limit']) {
316 if ($GLOBALS['output_charset_conversion']) {
317 $dump_buffer = PMA_convert_string(
319 $GLOBALS['charset_of_file'],
324 if ($GLOBALS['compression'] == 'bzip2'
325 && @function_exists
('bzcompress')
327 $dump_buffer = bzcompress($dump_buffer);
328 } elseif ($GLOBALS['compression'] == 'gzip'
329 && PMA_gzencodeNeeded()
332 // without the optional parameter level because it bugs
333 $dump_buffer = gzencode($dump_buffer);
335 if ($GLOBALS['save_on_server']) {
336 $write_result = @fwrite
($GLOBALS['file_handle'], $dump_buffer);
337 if (! $write_result ||
($write_result != strlen($dump_buffer))) {
338 $GLOBALS['message'] = PMA_Message
::error(
339 __('Insufficient space to save the file %s.')
341 $GLOBALS['message']->addParam($save_filename);
348 $dump_buffer_len = 0;
352 if ($time_start >= $time_now +
30) {
353 $time_start = $time_now;
354 header('X-pmaPing: Pong');
358 if ($GLOBALS['asfile']) {
359 if ($GLOBALS['output_charset_conversion']) {
360 $line = PMA_convert_string(
362 $GLOBALS['charset_of_file'],
366 if ($GLOBALS['save_on_server'] && strlen($line) > 0) {
367 $write_result = @fwrite
($GLOBALS['file_handle'], $line);
368 if (! $write_result ||
($write_result != strlen($line))) {
369 $GLOBALS['message'] = PMA_Message
::error(
370 __('Insufficient space to save the file %s.')
372 $GLOBALS['message']->addParam($save_filename);
376 if ($time_start >= $time_now +
30) {
377 $time_start = $time_now;
378 header('X-pmaPing: Pong');
381 // We export as file - output normally
385 // We export as html - replace special chars
386 echo htmlspecialchars($line);
390 } // end of the 'PMA_exportOutputHandler()' function
392 // Defines the default <CR><LF> format.
393 // For SQL always use \n as MySQL wants this on all platforms.
394 if ($what == 'sql') {
397 $crlf = PMA_Util
::whichCrlf();
400 $output_kanji_conversion = function_exists('PMA_kanji_str_conv') && $type != 'xls';
402 // Do we need to convert charset?
403 $output_charset_conversion = $asfile
404 && $GLOBALS['PMA_recoding_engine'] != PMA_CHARSET_NONE
405 && isset($charset_of_file) && $charset_of_file != 'utf-8'
408 // Use on the fly compression?
409 $onfly_compression = $GLOBALS['cfg']['CompressOnFly']
410 && ($compression == 'gzip' ||
$compression == 'bzip2');
411 if ($onfly_compression) {
412 $memory_limit = trim(@ini_get
('memory_limit'));
414 if (empty($memory_limit)) {
415 $memory_limit = 2 * 1024 * 1024;
418 if (strtolower(substr($memory_limit, -1)) == 'm') {
419 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024;
420 } elseif (strtolower(substr($memory_limit, -1)) == 'k') {
421 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024;
422 } elseif (strtolower(substr($memory_limit, -1)) == 'g') {
423 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024 * 1024;
425 $memory_limit = (int)$memory_limit;
428 // Some of memory is needed for other thins and as treshold.
429 // Nijel: During export I had allocated (see memory_get_usage function)
430 // approx 1.2MB so this comes from that.
431 if ($memory_limit > 1500000) {
432 $memory_limit -= 1500000;
435 // Some memory is needed for compression, assume 1/3
439 // Generate filename and mime type if needed
441 $pma_uri_parts = parse_url($cfg['PmaAbsoluteUri']);
442 if ($export_type == 'server') {
443 if (isset($remember_template)) {
444 $GLOBALS['PMA_Config']->setUserValue(
445 'pma_server_filename_template',
446 'Export/file_template_server',
450 } elseif ($export_type == 'database') {
451 if (isset($remember_template)) {
452 $GLOBALS['PMA_Config']->setUserValue(
453 'pma_db_filename_template',
454 'Export/file_template_database',
459 if (isset($remember_template)) {
460 $GLOBALS['PMA_Config']->setUserValue(
461 'pma_table_filename_template',
462 'Export/file_template_table',
467 $filename = PMA_Util
::expandUserString($filename_template);
468 // remove dots in filename (coming from either the template or already
469 // part of the filename) to avoid a remote code execution vulnerability
470 $filename = PMA_sanitizeFilename($filename, $replaceDots = true);
472 // Grab basic dump extension and mime type
473 // Check if the user already added extension;
474 // get the substring where the extension would be if it was included
475 $extension_start_pos = strlen($filename) - strlen(
476 $export_plugin->getProperties()->getExtension()
478 $user_extension = substr($filename, $extension_start_pos, strlen($filename));
479 $required_extension = "." . $export_plugin->getProperties()->getExtension();
480 if (strtolower($user_extension) != $required_extension) {
481 $filename .= $required_extension;
483 $mime_type = $export_plugin->getProperties()->getMimeType();
485 // If dump is going to be compressed, set correct mime_type and add
486 // compression to extension
487 if ($compression == 'bzip2') {
489 $mime_type = 'application/x-bzip2';
490 } elseif ($compression == 'gzip') {
492 $mime_type = 'application/x-gzip';
493 } elseif ($compression == 'zip') {
495 $mime_type = 'application/zip';
499 // Open file on server if needed
500 if ($save_on_server) {
501 $save_filename = PMA_Util
::userDir($cfg['SaveDir'])
502 . preg_replace('@[/\\\\]@', '_', $filename);
504 if (file_exists($save_filename)
505 && ((! $quick_export && empty($_REQUEST['onserverover']))
507 && $_REQUEST['quick_export_onserverover'] != 'saveitover'))
509 $message = PMA_Message
::error(
510 __('File %s already exists on server, change filename or check overwrite option.')
512 $message->addParam($save_filename);
514 if (is_file($save_filename) && ! is_writable($save_filename)) {
515 $message = PMA_Message
::error(
516 __('The web server does not have permission to save the file %s.')
518 $message->addParam($save_filename);
520 if (! $file_handle = @fopen
($save_filename, 'w')) {
521 $message = PMA_Message
::error(
522 __('The web server does not have permission to save the file %s.')
524 $message->addParam($save_filename);
528 if (isset($message)) {
529 if ($export_type == 'server') {
530 $active_page = 'server_export.php';
531 include 'server_export.php';
532 } elseif ($export_type == 'database') {
533 $active_page = 'db_export.php';
534 include 'db_export.php';
536 $active_page = 'tbl_export.php';
537 include 'tbl_export.php';
544 * Send headers depending on whether the user chose to download a dump file
547 if (! $save_on_server) {
550 // (avoid rewriting data containing HTML with anchors and forms;
551 // this was reported to happen under Plesk)
552 @ini_set
('url_rewriter.tags', '');
553 $filename = PMA_sanitizeFilename($filename);
555 PMA_downloadHeader($filename, $mime_type);
558 if ($export_type == 'database') {
559 $num_tables = count($tables);
560 if ($num_tables == 0) {
561 $message = PMA_Message
::error(__('No tables found in database.'));
562 $active_page = 'db_export.php';
563 include 'db_export.php';
567 $backup_cfgServer = $cfg['Server'];
568 $cfg['Server'] = $backup_cfgServer;
569 unset($backup_cfgServer);
570 echo "\n" . '<div style="text-align: ' . $cell_align_left . '">' . "\n";
571 //echo ' <pre>' . "\n";
574 * Displays a back button with all the $_REQUEST data in the URL
575 * (store in a variable to also display after the textarea)
577 $back_button = '<p>[ <a href="';
578 if ($export_type == 'server') {
579 $back_button .= 'server_export.php?' . PMA_generate_common_url();
580 } elseif ($export_type == 'database') {
581 $back_button .= 'db_export.php?' . PMA_generate_common_url($db);
583 $back_button .= 'tbl_export.php?' . PMA_generate_common_url($db, $table);
586 // Convert the multiple select elements from an array to a string
587 if ($export_type == 'server' && isset($_REQUEST['db_select'])) {
588 $_REQUEST['db_select'] = implode(",", $_REQUEST['db_select']);
589 } elseif ($export_type == 'database' && isset($_REQUEST['table_select'])) {
590 $_REQUEST['table_select'] = implode(",", $_REQUEST['table_select']);
593 foreach ($_REQUEST as $name => $value) {
594 $back_button .= '&' . urlencode($name) . '=' . urlencode($value);
596 $back_button .= '&repopulate=1">Back</a> ]</p>';
599 echo ' <form name="nofunction">' . "\n"
600 // remove auto-select for now: there is no way to select
601 // only a part of the text; anyway, it should obey
602 // $cfg['TextareaAutoSelect']
603 //. ' <textarea name="sqldump" cols="50" rows="30" onclick="this.select();" id="textSQLDUMP" wrap="OFF">' . "\n";
604 . ' <textarea name="sqldump" cols="50" rows="30" id="textSQLDUMP" wrap="OFF">' . "\n";
608 // Fake loop just to allow skip of remain of this code by break, I'd really
609 // need exceptions here :-)
612 // Add possibly some comments to export
613 if (! $export_plugin->exportHeader($db)) {
617 // Will we need relation & co. setup?
618 $do_relation = isset($GLOBALS[$what . '_relation']);
619 $do_comments = isset($GLOBALS[$what . '_include_comments']);
620 $do_mime = isset($GLOBALS[$what . '_mime']);
621 if ($do_relation ||
$do_comments ||
$do_mime) {
622 $cfgRelation = PMA_getRelationsParam();
625 include_once 'libraries/transformations.lib.php';
628 // Include dates in export?
629 $do_dates = isset($GLOBALS[$what . '_dates']);
634 // Gets the number of tables if a dump of a database has been required
635 if ($export_type == 'server') {
636 if (isset($db_select)) {
637 $tmp_select = implode($db_select, '|');
638 $tmp_select = '|' . $tmp_select . '|';
640 // Walk over databases
641 foreach ($GLOBALS['pma']->databases
as $current_db) {
642 if (isset($tmp_select)
643 && strpos(' ' . $tmp_select, '|' . $current_db . '|')
645 if (! $export_plugin->exportDBHeader($current_db)) {
648 if (! $export_plugin->exportDBCreate($current_db)) {
651 if (method_exists($export_plugin, 'exportRoutines')
652 && strpos($GLOBALS['sql_structure_or_data'], 'structure') !== false
653 && isset($GLOBALS['sql_procedure_function'])
655 $export_plugin->exportRoutines($current_db);
658 $tables = PMA_DBI_get_tables($current_db);
660 foreach ($tables as $table) {
661 // if this is a view, collect it for later;
662 // views must be exported after the tables
663 $is_view = PMA_Table
::isView($current_db, $table);
667 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
668 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
670 // for a view, export a stand-in definition of the table
671 // to resolve view dependencies
672 if (! $export_plugin->exportStructure(
673 $current_db, $table, $crlf, $err_url,
674 $is_view ?
'stand_in' : 'create_table', $export_type,
675 $do_relation, $do_comments, $do_mime, $do_dates
680 // if this is a view or a merge table, don't export data
681 if (($GLOBALS[$what . '_structure_or_data'] == 'data'
682 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data')
683 && ! ($is_view || PMA_Table
::isMerge($current_db, $table))
685 $local_query = 'SELECT * FROM ' . PMA_Util
::backquote($current_db)
686 . '.' . PMA_Util
::backquote($table);
687 if (! $export_plugin->exportData($current_db, $table, $crlf, $err_url, $local_query)) {
691 // now export the triggers (needs to be done after the data
692 // because triggers can modify already imported tables)
693 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
694 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
696 if (! $export_plugin->exportStructure(
697 $current_db, $table, $crlf, $err_url,
698 'triggers', $export_type,
699 $do_relation, $do_comments, $do_mime, $do_dates
705 foreach ($views as $view) {
706 // no data export for a view
707 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
708 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
710 if (! $export_plugin->exportStructure(
711 $current_db, $view, $crlf, $err_url,
712 'create_view', $export_type,
713 $do_relation, $do_comments, $do_mime, $do_dates
719 if (! $export_plugin->exportDBFooter($current_db)) {
724 } elseif ($export_type == 'database') {
725 if (! $export_plugin->exportDBHeader($db)) {
728 if (! $export_plugin->exportDBCreate($db)) {
732 if (method_exists($export_plugin, 'exportRoutines')
733 && strpos($GLOBALS['sql_structure_or_data'], 'structure') !== false
734 && isset($GLOBALS['sql_procedure_function'])
736 $export_plugin->exportRoutines($db);
741 // $tables contains the choices from the user (via $table_select)
742 foreach ($tables as $table) {
743 // if this is a view, collect it for later; views must be exported after
745 $is_view = PMA_Table
::isView($db, $table);
749 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
750 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
752 // for a view, export a stand-in definition of the table
753 // to resolve view dependencies
754 if (! $export_plugin->exportStructure(
755 $db, $table, $crlf, $err_url,
756 $is_view ?
'stand_in' : 'create_table', $export_type,
757 $do_relation, $do_comments, $do_mime, $do_dates
762 // if this is a view or a merge table, don't export data
763 if (($GLOBALS[$what . '_structure_or_data'] == 'data'
764 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data')
765 && ! ($is_view || PMA_Table
::isMerge($db, $table))
767 $local_query = 'SELECT * FROM ' . PMA_Util
::backquote($db)
768 . '.' . PMA_Util
::backquote($table);
769 if (! $export_plugin->exportData($db, $table, $crlf, $err_url, $local_query)) {
773 // now export the triggers (needs to be done after the data because
774 // triggers can modify already imported tables)
775 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
776 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
778 if (! $export_plugin->exportStructure(
779 $db, $table, $crlf, $err_url,
780 'triggers', $export_type,
781 $do_relation, $do_comments, $do_mime, $do_dates
787 foreach ($views as $view) {
788 // no data export for a view
789 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
790 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
792 if (! $export_plugin->exportStructure(
793 $db, $view, $crlf, $err_url,
794 'create_view', $export_type,
795 $do_relation, $do_comments, $do_mime, $do_dates
802 if (! $export_plugin->exportDBFooter($db)) {
806 if (! $export_plugin->exportDBHeader($db)) {
809 // We export just one table
810 // $allrows comes from the form when "Dump all rows" has been selected
811 if (isset($allrows) && $allrows == '0' && $limit_to > 0 && $limit_from >= 0) {
812 $add_query = ' LIMIT '
813 . (($limit_from > 0) ?
$limit_from . ', ' : '')
819 $is_view = PMA_Table
::isView($db, $table);
820 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
821 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
823 if (! $export_plugin->exportStructure(
824 $db, $table, $crlf, $err_url,
825 $is_view ?
'create_view' : 'create_table', $export_type,
826 $do_relation, $do_comments, $do_mime, $do_dates
831 // If this is an export of a single view, we have to export data;
832 // for example, a PDF report
833 // if it is a merge table, no data is exported
834 if (($GLOBALS[$what . '_structure_or_data'] == 'data'
835 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data')
836 && ! PMA_Table
::isMerge($db, $table)
838 if (! empty($sql_query)) {
839 // only preg_replace if needed
840 if (! empty($add_query)) {
841 // remove trailing semicolon before adding a LIMIT
842 $sql_query = preg_replace('%;\s*$%', '', $sql_query);
844 $local_query = $sql_query . $add_query;
845 PMA_DBI_select_db($db);
847 $local_query = 'SELECT * FROM ' . PMA_Util
::backquote($db)
848 . '.' . PMA_Util
::backquote($table) . $add_query;
850 if (! $export_plugin->exportData($db, $table, $crlf, $err_url, $local_query)) {
854 // now export the triggers (needs to be done after the data because
855 // triggers can modify already imported tables)
856 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
857 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
859 if (! $export_plugin->exportStructure(
860 $db, $table, $crlf, $err_url,
861 'triggers', $export_type,
862 $do_relation, $do_comments, $do_mime, $do_dates
867 if (! $export_plugin->exportDBFooter($db)) {
871 if (! $export_plugin->exportFooter()) {
878 if ($save_on_server && isset($message)) {
879 if ($export_type == 'server') {
880 $active_page = 'server_export.php';
881 include 'server_export.php';
882 } elseif ($export_type == 'database') {
883 $active_page = 'db_export.php';
884 include 'db_export.php';
886 $active_page = 'tbl_export.php';
887 include 'tbl_export.php';
893 * Send the dump as a file...
895 if (! empty($asfile)) {
896 // Convert the charset if required.
897 if ($output_charset_conversion) {
898 $dump_buffer = PMA_convert_string(
900 $GLOBALS['charset_of_file'],
905 // Do the compression
906 // 1. as a zipped file
907 if ($compression == 'zip') {
908 if (@function_exists
('gzcompress')) {
909 $zipfile = new ZipFile();
910 $zipfile->addFile($dump_buffer, substr($filename, 0, -4));
911 $dump_buffer = $zipfile->file();
913 } elseif ($compression == 'bzip2') {
914 // 2. as a bzipped file
915 if (@function_exists
('bzcompress')) {
916 $dump_buffer = bzcompress($dump_buffer);
918 } elseif ($compression == 'gzip' && PMA_gzencodeNeeded()) {
919 // 3. as a gzipped file
920 // without the optional parameter level because it bugs
921 $dump_buffer = gzencode($dump_buffer);
924 /* If we saved on server, we have to close file now */
925 if ($save_on_server) {
926 $write_result = @fwrite
($file_handle, $dump_buffer);
927 fclose($file_handle);
928 if (strlen($dump_buffer) > 0
929 && (! $write_result ||
($write_result != strlen($dump_buffer)))
931 $message = new PMA_Message(
932 __('Insufficient space to save the file %s.'),
937 $message = new PMA_Message(
938 __('Dump has been saved to file %s.'),
939 PMA_Message
::SUCCESS
,
944 if ($export_type == 'server') {
945 $active_page = 'server_export.php';
946 include_once 'server_export.php';
947 } elseif ($export_type == 'database') {
948 $active_page = 'db_export.php';
949 include_once 'db_export.php';
951 $active_page = 'tbl_export.php';
952 include_once 'tbl_export.php';
956 PMA_Response
::getInstance()->disable();
961 * Displays the dump...
963 * Close the html tags and add the footers if dump is displayed on screen
965 echo '</textarea>' . "\n"
970 echo '</div>' . "\n";
973 <script type
="text/javascript">
975 var $body = $
("body");
977 .width($body.width() - 50)
978 .height($body.height() - 100);