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
39 'htmlword_structure_or_data',
42 'mediawiki_structure_or_data',
45 'pdf_structure_or_data',
46 'odt_structure_or_data',
52 'codegen_structure_or_data',
57 'excel_structure_or_data',
58 'yaml_structure_or_data',
60 'ods_structure_or_data',
62 'json_structure_or_data',
63 'xml_structure_or_data',
64 'xml_export_functions',
65 'xml_export_procedures',
67 'xml_export_triggers',
69 'xml_export_contents',
70 'texytext_structure_or_data',
73 'phparray_structure_or_data',
74 'sql_include_comments',
79 'sql_use_transaction',
82 'sql_structure_or_data',
84 'sql_procedure_function',
85 'sql_create_table_statements',
103 'csv_structure_or_data',
105 'latex_structure_or_data',
106 'latex_structure_caption',
107 'latex_structure_continued_caption',
108 'latex_structure_label',
113 'latex_data_caption',
114 'latex_data_continued_caption',
119 foreach ($post_params as $one_post_param) {
120 if (isset($_POST[$one_post_param])) {
121 $GLOBALS[$one_post_param] = $_POST[$one_post_param];
125 // sanitize this parameter which will be used below in a file inclusion
126 $what = PMA_securePath($what);
128 PMA_Util
::checkParameters(array('what', 'export_type'));
130 // export class instance, not array of properties, as before
131 $export_plugin = PMA_getPlugin(
134 'libraries/plugins/export/',
136 'export_type' => $export_type,
137 'single_table' => isset($single_table)
141 // Backward compatbility
145 if (! isset($export_plugin)) {
146 PMA_fatalError(__('Bad type!'));
150 * valid compression methods
152 $compression_methods = array(
159 * init and variable checking
161 $compression = false;
163 $save_on_server = false;
164 $buffer_needed = false;
166 // Is it a quick or custom export?
167 if ($_REQUEST['quick_or_custom'] == 'quick') {
168 $quick_export = true;
170 $quick_export = false;
173 if ($_REQUEST['output_format'] == 'astext') {
177 if (in_array($_REQUEST['compression'], $compression_methods)) {
178 $compression = $_REQUEST['compression'];
179 $buffer_needed = true;
181 if (($quick_export && ! empty($_REQUEST['quick_export_onserver']))
182 ||
(! $quick_export && ! empty($_REQUEST['onserver']))
185 $onserver = $_REQUEST['quick_export_onserver'];
187 $onserver = $_REQUEST['onserver'];
189 // Will we save dump on server?
190 $save_on_server = ! empty($cfg['SaveDir']) && $onserver;
194 // Does export require to be into file?
195 if ($export_plugin->getProperties()->getForceFile() != null && ! $asfile) {
196 $message = PMA_Message
::error(
197 __('Selected export type has to be saved in file!')
199 if ($export_type == 'server') {
200 $active_page = 'server_export.php';
201 include 'server_export.php';
202 } elseif ($export_type == 'database') {
203 $active_page = 'db_export.php';
204 include 'db_export.php';
206 $active_page = 'tbl_export.php';
207 include 'tbl_export.php';
212 // Generate error url and check for needed variables
213 if ($export_type == 'server') {
214 $err_url = 'server_export.php?' . PMA_generate_common_url();
215 } elseif ($export_type == 'database' && strlen($db)) {
216 $err_url = 'db_export.php?' . PMA_generate_common_url($db);
217 // Check if we have something to export
218 if (isset($table_select)) {
219 $tables = $table_select;
223 } elseif ($export_type == 'table' && strlen($db) && strlen($table)) {
224 $err_url = 'tbl_export.php?' . PMA_generate_common_url($db, $table);
226 PMA_fatalError(__('Bad parameters!'));
230 * Increase time limit for script execution and initializes some variables
232 @set_time_limit
($cfg['ExecTimeLimit']);
233 if (! empty($cfg['MemoryLimit'])) {
234 @ini_set
('memory_limit', $cfg['MemoryLimit']);
237 // Start with empty buffer
239 $dump_buffer_len = 0;
241 // We send fake headers to avoid browser timeout when buffering
242 $time_start = time();
246 * Detect ob_gzhandler
250 function PMA_isGzHandlerEnabled()
252 return in_array('ob_gzhandler', ob_list_handlers());
256 * Detect whether gzencode is needed; it might not be needed if
257 * the server is already compressing by itself
259 * @return bool Whether gzencode is needed
261 function PMA_gzencodeNeeded()
263 if (@function_exists
('gzencode')
264 && ! @ini_get
('zlib.output_compression')
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 && ! (function_exists('apache_get_modules')
269 && in_array('mod_deflate', apache_get_modules()))
270 && ! PMA_isGzHandlerEnabled()
279 * Output handler for all exports, if needed buffering, it stores data into
280 * $dump_buffer, otherwise it prints thems out.
282 * @param string $line the insert statement
284 * @return bool Whether output succeeded
286 function PMA_exportOutputHandler($line)
288 global $time_start, $dump_buffer, $dump_buffer_len, $save_filename;
290 // Kanji encoding convert feature
291 if ($GLOBALS['output_kanji_conversion']) {
292 $line = PMA_kanji_str_conv(
295 isset($GLOBALS['xkana']) ?
$GLOBALS['xkana'] : ''
298 // If we have to buffer data, we will perform everything at once at the end
299 if ($GLOBALS['buffer_needed']) {
301 $dump_buffer .= $line;
302 if ($GLOBALS['onfly_compression']) {
304 $dump_buffer_len +
= strlen($line);
306 if ($dump_buffer_len > $GLOBALS['memory_limit']) {
307 if ($GLOBALS['output_charset_conversion']) {
308 $dump_buffer = PMA_convert_string(
310 $GLOBALS['charset_of_file'],
315 if ($GLOBALS['compression'] == 'bzip2'
316 && @function_exists
('bzcompress')
318 $dump_buffer = bzcompress($dump_buffer);
319 } elseif ($GLOBALS['compression'] == 'gzip'
320 && PMA_gzencodeNeeded()
323 // without the optional parameter level because it bugs
324 $dump_buffer = gzencode($dump_buffer);
326 if ($GLOBALS['save_on_server']) {
327 $write_result = @fwrite
($GLOBALS['file_handle'], $dump_buffer);
328 if (! $write_result ||
($write_result != strlen($dump_buffer))) {
329 $GLOBALS['message'] = PMA_Message
::error(
330 __('Insufficient space to save the file %s.')
332 $GLOBALS['message']->addParam($save_filename);
339 $dump_buffer_len = 0;
343 if ($time_start >= $time_now +
30) {
344 $time_start = $time_now;
345 header('X-pmaPing: Pong');
349 if ($GLOBALS['asfile']) {
350 if ($GLOBALS['output_charset_conversion']) {
351 $line = PMA_convert_string(
353 $GLOBALS['charset_of_file'],
357 if ($GLOBALS['save_on_server'] && strlen($line) > 0) {
358 $write_result = @fwrite
($GLOBALS['file_handle'], $line);
359 if (! $write_result ||
($write_result != strlen($line))) {
360 $GLOBALS['message'] = PMA_Message
::error(
361 __('Insufficient space to save the file %s.')
363 $GLOBALS['message']->addParam($save_filename);
367 if ($time_start >= $time_now +
30) {
368 $time_start = $time_now;
369 header('X-pmaPing: Pong');
372 // We export as file - output normally
376 // We export as html - replace special chars
377 echo htmlspecialchars($line);
381 } // end of the 'PMA_exportOutputHandler()' function
383 // Defines the default <CR><LF> format.
384 // For SQL always use \n as MySQL wants this on all platforms.
385 if ($what == 'sql') {
388 $crlf = PMA_Util
::whichCrlf();
391 $output_kanji_conversion = function_exists('PMA_kanji_str_conv') && $type != 'xls';
393 // Do we need to convert charset?
394 $output_charset_conversion = $asfile
395 && $GLOBALS['PMA_recoding_engine'] != PMA_CHARSET_NONE
396 && isset($charset_of_file) && $charset_of_file != 'utf-8'
399 // Use on the fly compression?
400 $onfly_compression = $GLOBALS['cfg']['CompressOnFly']
401 && ($compression == 'gzip' ||
$compression == 'bzip2');
402 if ($onfly_compression) {
403 $memory_limit = trim(@ini_get
('memory_limit'));
405 if (empty($memory_limit)) {
406 $memory_limit = 2 * 1024 * 1024;
409 if (strtolower(substr($memory_limit, -1)) == 'm') {
410 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024;
411 } elseif (strtolower(substr($memory_limit, -1)) == 'k') {
412 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024;
413 } elseif (strtolower(substr($memory_limit, -1)) == 'g') {
414 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024 * 1024;
416 $memory_limit = (int)$memory_limit;
419 // Some of memory is needed for other thins and as treshold.
420 // Nijel: During export I had allocated (see memory_get_usage function)
421 // approx 1.2MB so this comes from that.
422 if ($memory_limit > 1500000) {
423 $memory_limit -= 1500000;
426 // Some memory is needed for compression, assume 1/3
430 // Generate filename and mime type if needed
432 $pma_uri_parts = parse_url($cfg['PmaAbsoluteUri']);
433 if ($export_type == 'server') {
434 if (isset($remember_template)) {
435 $GLOBALS['PMA_Config']->setUserValue(
436 'pma_server_filename_template',
437 'Export/file_template_server',
441 } elseif ($export_type == 'database') {
442 if (isset($remember_template)) {
443 $GLOBALS['PMA_Config']->setUserValue(
444 'pma_db_filename_template',
445 'Export/file_template_database',
450 if (isset($remember_template)) {
451 $GLOBALS['PMA_Config']->setUserValue(
452 'pma_table_filename_template',
453 'Export/file_template_table',
458 $filename = PMA_Util
::expandUserString($filename_template);
459 $filename = PMA_sanitizeFilename($filename);
461 // Grab basic dump extension and mime type
462 // Check if the user already added extension;
463 // get the substring where the extension would be if it was included
464 $extension_start_pos = strlen($filename) - strlen(
465 $export_plugin->getProperties()->getExtension()
467 $user_extension = substr($filename, $extension_start_pos, strlen($filename));
468 $required_extension = "." . $export_plugin->getProperties()->getExtension();
469 if (strtolower($user_extension) != $required_extension) {
470 $filename .= $required_extension;
472 $mime_type = $export_plugin->getProperties()->getMimeType();
474 // If dump is going to be compressed, set correct mime_type and add
475 // compression to extension
476 if ($compression == 'bzip2') {
478 $mime_type = 'application/x-bzip2';
479 } elseif ($compression == 'gzip') {
481 $mime_type = 'application/x-gzip';
482 } elseif ($compression == 'zip') {
484 $mime_type = 'application/zip';
488 // Open file on server if needed
489 if ($save_on_server) {
490 $save_filename = PMA_Util
::userDir($cfg['SaveDir'])
491 . preg_replace('@[/\\\\]@', '_', $filename);
493 if (file_exists($save_filename)
494 && ((! $quick_export && empty($onserverover))
496 && $_REQUEST['quick_export_onserverover'] != 'saveitover'))
498 $message = PMA_Message
::error(
499 __('File %s already exists on server, change filename or check overwrite option.')
501 $message->addParam($save_filename);
503 if (is_file($save_filename) && ! is_writable($save_filename)) {
504 $message = PMA_Message
::error(
505 __('The web server does not have permission to save the file %s.')
507 $message->addParam($save_filename);
509 if (! $file_handle = @fopen
($save_filename, 'w')) {
510 $message = PMA_Message
::error(
511 __('The web server does not have permission to save the file %s.')
513 $message->addParam($save_filename);
517 if (isset($message)) {
518 if ($export_type == 'server') {
519 $active_page = 'server_export.php';
520 include 'server_export.php';
521 } elseif ($export_type == 'database') {
522 $active_page = 'db_export.php';
523 include 'db_export.php';
525 $active_page = 'tbl_export.php';
526 include 'tbl_export.php';
533 * Send headers depending on whether the user chose to download a dump file
536 if (! $save_on_server) {
539 // (avoid rewriting data containing HTML with anchors and forms;
540 // this was reported to happen under Plesk)
541 @ini_set
('url_rewriter.tags', '');
542 $filename = PMA_sanitizeFilename($filename);
544 PMA_downloadHeader($filename, $mime_type);
547 if ($export_type == 'database') {
548 $num_tables = count($tables);
549 if ($num_tables == 0) {
550 $message = PMA_Message
::error(__('No tables found in database.'));
551 $active_page = 'db_export.php';
552 include 'db_export.php';
556 $backup_cfgServer = $cfg['Server'];
557 $cfg['Server'] = $backup_cfgServer;
558 unset($backup_cfgServer);
559 echo "\n" . '<div style="text-align: ' . $cell_align_left . '">' . "\n";
560 //echo ' <pre>' . "\n";
563 * Displays a back button with all the $_REQUEST data in the URL
564 * (store in a variable to also display after the textarea)
566 $back_button = '<p>[ <a href="';
567 if ($export_type == 'server') {
568 $back_button .= 'server_export.php?' . PMA_generate_common_url();
569 } elseif ($export_type == 'database') {
570 $back_button .= 'db_export.php?' . PMA_generate_common_url($db);
572 $back_button .= 'tbl_export.php?' . PMA_generate_common_url($db, $table);
575 // Convert the multiple select elements from an array to a string
576 if ($export_type == 'server' && isset($_REQUEST['db_select'])) {
577 $_REQUEST['db_select'] = implode(",", $_REQUEST['db_select']);
578 } elseif ($export_type == 'database' && isset($_REQUEST['table_select'])) {
579 $_REQUEST['table_select'] = implode(",", $_REQUEST['table_select']);
582 foreach ($_REQUEST as $name => $value) {
583 $back_button .= '&' . urlencode($name) . '=' . urlencode($value);
585 $back_button .= '&repopulate=1">Back</a> ]</p>';
588 echo ' <form name="nofunction">' . "\n"
589 // remove auto-select for now: there is no way to select
590 // only a part of the text; anyway, it should obey
591 // $cfg['TextareaAutoSelect']
592 //. ' <textarea name="sqldump" cols="50" rows="30" onclick="this.select();" id="textSQLDUMP" wrap="OFF">' . "\n";
593 . ' <textarea name="sqldump" cols="50" rows="30" id="textSQLDUMP" wrap="OFF">' . "\n";
597 // Fake loop just to allow skip of remain of this code by break, I'd really
598 // need exceptions here :-)
601 // Add possibly some comments to export
602 if (! $export_plugin->exportHeader($db)) {
606 // Will we need relation & co. setup?
607 $do_relation = isset($GLOBALS[$what . '_relation']);
608 $do_comments = isset($GLOBALS[$what . '_include_comments']);
609 $do_mime = isset($GLOBALS[$what . '_mime']);
610 if ($do_relation ||
$do_comments ||
$do_mime) {
611 $cfgRelation = PMA_getRelationsParam();
614 include_once 'libraries/transformations.lib.php';
617 // Include dates in export?
618 $do_dates = isset($GLOBALS[$what . '_dates']);
623 // Gets the number of tables if a dump of a database has been required
624 if ($export_type == 'server') {
625 if (isset($db_select)) {
626 $tmp_select = implode($db_select, '|');
627 $tmp_select = '|' . $tmp_select . '|';
629 // Walk over databases
630 foreach ($GLOBALS['pma']->databases
as $current_db) {
631 if ((isset($tmp_select)
632 && strpos(' ' . $tmp_select, '|' . $current_db . '|'))
633 ||
! isset($tmp_select)
635 if (! $export_plugin->exportDBHeader($current_db)) {
638 if (! $export_plugin->exportDBCreate($current_db)) {
641 if (method_exists($export_plugin, 'exportRoutines')
642 && strpos($GLOBALS['sql_structure_or_data'], 'structure') !== false
643 && isset($GLOBALS['sql_procedure_function'])
645 $export_plugin->exportRoutines($current_db);
648 $tables = PMA_DBI_get_tables($current_db);
650 foreach ($tables as $table) {
651 // if this is a view, collect it for later;
652 // views must be exported after the tables
653 $is_view = PMA_Table
::isView($current_db, $table);
657 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
658 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
660 // for a view, export a stand-in definition of the table
661 // to resolve view dependencies
662 if (! $export_plugin->exportStructure(
663 $current_db, $table, $crlf, $err_url,
664 $is_view ?
'stand_in' : 'create_table', $export_type,
665 $do_relation, $do_comments, $do_mime, $do_dates
670 // if this is a view or a merge table, don't export data
671 if (($GLOBALS[$what . '_structure_or_data'] == 'data'
672 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data')
673 && ! ($is_view || PMA_Table
::isMerge($current_db, $table))
675 $local_query = 'SELECT * FROM ' . PMA_Util
::backquote($current_db)
676 . '.' . PMA_Util
::backquote($table);
677 if (! $export_plugin->exportData($current_db, $table, $crlf, $err_url, $local_query)) {
681 // now export the triggers (needs to be done after the data
682 // because triggers can modify already imported tables)
683 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
684 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
686 if (! $export_plugin->exportStructure(
687 $current_db, $table, $crlf, $err_url,
688 'triggers', $export_type,
689 $do_relation, $do_comments, $do_mime, $do_dates
695 foreach ($views as $view) {
696 // no data export for a view
697 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
698 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
700 if (! $export_plugin->exportStructure(
701 $current_db, $view, $crlf, $err_url,
702 'create_view', $export_type,
703 $do_relation, $do_comments, $do_mime, $do_dates
709 if (! $export_plugin->exportDBFooter($current_db)) {
714 } elseif ($export_type == 'database') {
715 if (! $export_plugin->exportDBHeader($db)) {
719 if (method_exists($export_plugin, 'exportRoutines')
720 && strpos($GLOBALS['sql_structure_or_data'], 'structure') !== false
721 && isset($GLOBALS['sql_procedure_function'])
723 $export_plugin->exportRoutines($db);
728 // $tables contains the choices from the user (via $table_select)
729 foreach ($tables as $table) {
730 // if this is a view, collect it for later; views must be exported after
732 $is_view = PMA_Table
::isView($db, $table);
736 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
737 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
739 // for a view, export a stand-in definition of the table
740 // to resolve view dependencies
741 if (! $export_plugin->exportStructure(
742 $db, $table, $crlf, $err_url,
743 $is_view ?
'stand_in' : 'create_table', $export_type,
744 $do_relation, $do_comments, $do_mime, $do_dates
749 // if this is a view or a merge table, don't export data
750 if (($GLOBALS[$what . '_structure_or_data'] == 'data'
751 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data')
752 && ! ($is_view || PMA_Table
::isMerge($db, $table))
754 $local_query = 'SELECT * FROM ' . PMA_Util
::backquote($db)
755 . '.' . PMA_Util
::backquote($table);
756 if (! $export_plugin->exportData($db, $table, $crlf, $err_url, $local_query)) {
760 // now export the triggers (needs to be done after the data because
761 // triggers can modify already imported tables)
762 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
763 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
765 if (! $export_plugin->exportStructure(
766 $db, $table, $crlf, $err_url,
767 'triggers', $export_type,
768 $do_relation, $do_comments, $do_mime, $do_dates
774 foreach ($views as $view) {
775 // no data export for a view
776 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
777 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
779 if (! $export_plugin->exportStructure(
780 $db, $view, $crlf, $err_url,
781 'create_view', $export_type,
782 $do_relation, $do_comments, $do_mime, $do_dates
789 if (! $export_plugin->exportDBFooter($db)) {
793 if (! $export_plugin->exportDBHeader($db)) {
796 // We export just one table
797 // $allrows comes from the form when "Dump all rows" has been selected
798 if (isset($allrows) && $allrows == '0' && $limit_to > 0 && $limit_from >= 0) {
799 $add_query = ' LIMIT '
800 . (($limit_from > 0) ?
$limit_from . ', ' : '')
806 $is_view = PMA_Table
::isView($db, $table);
807 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
808 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
810 if (! $export_plugin->exportStructure(
811 $db, $table, $crlf, $err_url,
812 $is_view ?
'create_view' : 'create_table', $export_type,
813 $do_relation, $do_comments, $do_mime, $do_dates
818 // If this is an export of a single view, we have to export data;
819 // for example, a PDF report
820 // if it is a merge table, no data is exported
821 if (($GLOBALS[$what . '_structure_or_data'] == 'data'
822 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data')
823 && ! PMA_Table
::isMerge($db, $table)
825 if (! empty($sql_query)) {
826 // only preg_replace if needed
827 if (! empty($add_query)) {
828 // remove trailing semicolon before adding a LIMIT
829 $sql_query = preg_replace('%;\s*$%', '', $sql_query);
831 $local_query = $sql_query . $add_query;
832 PMA_DBI_select_db($db);
834 $local_query = 'SELECT * FROM ' . PMA_Util
::backquote($db)
835 . '.' . PMA_Util
::backquote($table) . $add_query;
837 if (! $export_plugin->exportData($db, $table, $crlf, $err_url, $local_query)) {
841 // now export the triggers (needs to be done after the data because
842 // triggers can modify already imported tables)
843 if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
844 ||
$GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
846 if (! $export_plugin->exportStructure(
847 $db, $table, $crlf, $err_url,
848 'triggers', $export_type,
849 $do_relation, $do_comments, $do_mime, $do_dates
854 if (! $export_plugin->exportDBFooter($db)) {
858 if (! $export_plugin->exportFooter()) {
865 if ($save_on_server && isset($message)) {
866 if ($export_type == 'server') {
867 $active_page = 'server_export.php';
868 include 'server_export.php';
869 } elseif ($export_type == 'database') {
870 $active_page = 'db_export.php';
871 include 'db_export.php';
873 $active_page = 'tbl_export.php';
874 include 'tbl_export.php';
880 * Send the dump as a file...
882 if (! empty($asfile)) {
883 // Convert the charset if required.
884 if ($output_charset_conversion) {
885 $dump_buffer = PMA_convert_string(
887 $GLOBALS['charset_of_file'],
892 // Do the compression
893 // 1. as a zipped file
894 if ($compression == 'zip') {
895 if (@function_exists
('gzcompress')) {
896 $zipfile = new ZipFile();
897 $zipfile->addFile($dump_buffer, substr($filename, 0, -4));
898 $dump_buffer = $zipfile->file();
900 } elseif ($compression == 'bzip2') {
901 // 2. as a bzipped file
902 if (@function_exists
('bzcompress')) {
903 $dump_buffer = bzcompress($dump_buffer);
905 } elseif ($compression == 'gzip' && PMA_gzencodeNeeded()) {
906 // 3. as a gzipped file
907 // without the optional parameter level because it bugs
908 $dump_buffer = gzencode($dump_buffer);
911 /* If we saved on server, we have to close file now */
912 if ($save_on_server) {
913 $write_result = @fwrite
($file_handle, $dump_buffer);
914 fclose($file_handle);
915 if (strlen($dump_buffer) > 0
916 && (! $write_result ||
($write_result != strlen($dump_buffer)))
918 $message = new PMA_Message(
919 __('Insufficient space to save the file %s.'),
924 $message = new PMA_Message(
925 __('Dump has been saved to file %s.'),
926 PMA_Message
::SUCCESS
,
931 if ($export_type == 'server') {
932 $active_page = 'server_export.php';
933 include_once 'server_export.php';
934 } elseif ($export_type == 'database') {
935 $active_page = 'db_export.php';
936 include_once 'db_export.php';
938 $active_page = 'tbl_export.php';
939 include_once 'tbl_export.php';
943 PMA_Response
::getInstance()->disable();
948 * Displays the dump...
950 * Close the html tags and add the footers if dump is displayed on screen
952 echo '</textarea>' . "\n"
957 echo '</div>' . "\n";
960 <script type
="text/javascript">
962 var $body = $
("body");
964 .width($body.width() - 50)
965 .height($body.height() - 100);