Translation update done using Pootle.
[phpmyadmin/crack.git] / export.php
blob1a5d6e6451979c88410f68a790aee6044c7ad65a
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * @todo too much die here, or?
5 * @package phpMyAdmin
6 */
8 /**
9 * Get the variables sent or posted to this script and a core script
11 require_once './libraries/common.inc.php';
12 require_once './libraries/zip.lib.php';
13 require_once './libraries/plugin_interface.lib.php';
15 PMA_checkParameters(array('what', 'export_type'));
17 // Scan plugins
18 $export_list = PMA_getPlugins('./libraries/export/', array('export_type' => $export_type, 'single_table' => isset($single_table)));
20 // Backward compatbility
21 $type = $what;
23 // Check export type
24 if (!isset($export_list[$type])) {
25 die('Bad type!');
28 /**
29 * valid compression methods
31 $compression_methods = array(
32 'zip',
33 'gzip',
34 'bzip',
37 /**
38 * init and variable checking
40 $compression = false;
41 $onserver = false;
42 $save_on_server = false;
43 $buffer_needed = false;
45 // Is it a quick or custom export?
46 if($_REQUEST['quick_or_custom'] == 'quick') {
47 $quick_export = true;
48 } else {
49 $quick_export = false;
52 if ($_REQUEST['output_format'] == 'astext') {
53 $asfile = false;
54 } else {
55 $asfile = true;
56 if (in_array($_REQUEST['compression'], $compression_methods)) {
57 $compression = $_REQUEST['compression'];
58 $buffer_needed = true;
60 if (($quick_export && !empty($_REQUEST['quick_export_onserver'])) || (!$quick_export && !empty($_REQUEST['onserver']))) {
61 if($quick_export) {
62 $onserver = $_REQUEST['quick_export_onserver'];
63 } else {
64 $onserver = $_REQUEST['onserver'];
66 // Will we save dump on server?
67 $save_on_server = ! empty($cfg['SaveDir']) && $onserver;
71 // Does export require to be into file?
72 if (isset($export_list[$type]['force_file']) && ! $asfile) {
73 $message = PMA_Message::error(__('Selected export type has to be saved in file!'));
74 require_once './libraries/header.inc.php';
75 if ($export_type == 'server') {
76 $active_page = 'server_export.php';
77 require './server_export.php';
78 } elseif ($export_type == 'database') {
79 $active_page = 'db_export.php';
80 require './db_export.php';
81 } else {
82 $active_page = 'tbl_export.php';
83 require './tbl_export.php';
85 exit();
88 // Generate error url and check for needed variables
89 if ($export_type == 'server') {
90 $err_url = 'server_export.php?' . PMA_generate_common_url();
91 } elseif ($export_type == 'database' && strlen($db)) {
92 $err_url = 'db_export.php?' . PMA_generate_common_url($db);
93 // Check if we have something to export
94 if (isset($table_select)) {
95 $tables = $table_select;
96 } else {
97 $tables = array();
99 } elseif ($export_type == 'table' && strlen($db) && strlen($table)) {
100 $err_url = 'tbl_export.php?' . PMA_generate_common_url($db, $table);
101 } else {
102 die('Bad parameters!');
105 // Get the functions specific to the export type
106 require './libraries/export/' . PMA_securePath($type) . '.php';
109 * Increase time limit for script execution and initializes some variables
111 @set_time_limit($cfg['ExecTimeLimit']);
112 if (!empty($cfg['MemoryLimit'])) {
113 @ini_set('memory_limit', $cfg['MemoryLimit']);
116 // Start with empty buffer
117 $dump_buffer = '';
118 $dump_buffer_len = 0;
120 // We send fake headers to avoid browser timeout when buffering
121 $time_start = time();
125 * Output handler for all exports, if needed buffering, it stores data into
126 * $dump_buffer, otherwise it prints thems out.
128 * @param string the insert statement
130 * @return bool Whether output suceeded
132 function PMA_exportOutputHandler($line)
134 global $time_start, $dump_buffer, $dump_buffer_len, $save_filename;
136 // Kanji encoding convert feature
137 if ($GLOBALS['output_kanji_conversion']) {
138 $line = PMA_kanji_str_conv($line, $GLOBALS['knjenc'], isset($GLOBALS['xkana']) ? $GLOBALS['xkana'] : '');
140 // If we have to buffer data, we will perform everything at once at the end
141 if ($GLOBALS['buffer_needed']) {
143 $dump_buffer .= $line;
144 if ($GLOBALS['onfly_compression']) {
146 $dump_buffer_len += strlen($line);
148 if ($dump_buffer_len > $GLOBALS['memory_limit']) {
149 if ($GLOBALS['output_charset_conversion']) {
150 $dump_buffer = PMA_convert_string($GLOBALS['charset'], $GLOBALS['charset_of_file'], $dump_buffer);
152 // as bzipped
153 if ($GLOBALS['compression'] == 'bzip' && @function_exists('bzcompress')) {
154 $dump_buffer = bzcompress($dump_buffer);
156 // as a gzipped file
157 elseif ($GLOBALS['compression'] == 'gzip' && @function_exists('gzencode')) {
158 // without the optional parameter level because it bug
159 $dump_buffer = gzencode($dump_buffer);
161 if ($GLOBALS['save_on_server']) {
162 $write_result = @fwrite($GLOBALS['file_handle'], $dump_buffer);
163 if (!$write_result || ($write_result != strlen($dump_buffer))) {
164 $GLOBALS['message'] = PMA_Message::error(__('Insufficient space to save the file %s.'));
165 $GLOBALS['message']->addParam($save_filename);
166 return false;
168 } else {
169 echo $dump_buffer;
171 $dump_buffer = '';
172 $dump_buffer_len = 0;
174 } else {
175 $time_now = time();
176 if ($time_start >= $time_now + 30) {
177 $time_start = $time_now;
178 header('X-pmaPing: Pong');
179 } // end if
181 } else {
182 if ($GLOBALS['asfile']) {
183 if ($GLOBALS['output_charset_conversion']) {
184 $line = PMA_convert_string($GLOBALS['charset'], $GLOBALS['charset_of_file'], $line);
186 if ($GLOBALS['save_on_server'] && strlen($line) > 0) {
187 $write_result = @fwrite($GLOBALS['file_handle'], $line);
188 if (!$write_result || ($write_result != strlen($line))) {
189 $GLOBALS['message'] = PMA_Message::error(__('Insufficient space to save the file %s.'));
190 $GLOBALS['message']->addParam($save_filename);
191 return false;
193 $time_now = time();
194 if ($time_start >= $time_now + 30) {
195 $time_start = $time_now;
196 header('X-pmaPing: Pong');
197 } // end if
198 } else {
199 // We export as file - output normally
200 echo $line;
202 } else {
203 // We export as html - replace special chars
204 echo htmlspecialchars($line);
207 return true;
208 } // end of the 'PMA_exportOutputHandler()' function
210 // Defines the default <CR><LF> format. For SQL always use \n as MySQL wants this on all platforms.
211 if ($what == 'sql') {
212 $crlf = "\n";
213 } else {
214 $crlf = PMA_whichCrlf();
217 $output_kanji_conversion = function_exists('PMA_kanji_str_conv') && $type != 'xls';
219 // Do we need to convert charset?
220 $output_charset_conversion = $asfile && $GLOBALS['PMA_recoding_engine'] != PMA_CHARSET_NONE
221 && isset($charset_of_file) && $charset_of_file != $charset
222 && $type != 'xls';
224 // Use on the fly compression?
225 $onfly_compression = $GLOBALS['cfg']['CompressOnFly'] && ($compression == 'gzip' || $compression == 'bzip');
226 if ($onfly_compression) {
227 $memory_limit = trim(@ini_get('memory_limit'));
228 // 2 MB as default
229 if (empty($memory_limit)) {
230 $memory_limit = 2 * 1024 * 1024;
233 if (strtolower(substr($memory_limit, -1)) == 'm') {
234 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024;
235 } elseif (strtolower(substr($memory_limit, -1)) == 'k') {
236 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024;
237 } elseif (strtolower(substr($memory_limit, -1)) == 'g') {
238 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024 * 1024;
239 } else {
240 $memory_limit = (int)$memory_limit;
243 // Some of memory is needed for other thins and as treshold.
244 // Nijel: During export I had allocated (see memory_get_usage function)
245 // approx 1.2MB so this comes from that.
246 if ($memory_limit > 1500000) {
247 $memory_limit -= 1500000;
250 // Some memory is needed for compression, assume 1/3
251 $memory_limit /= 8;
254 // Generate filename and mime type if needed
255 if ($asfile) {
256 $pma_uri_parts = parse_url($cfg['PmaAbsoluteUri']);
257 if ($export_type == 'server') {
258 if (isset($remember_template)) {
259 $GLOBALS['PMA_Config']->setCookie('pma_server_filename_template', $filename_template);
261 } elseif ($export_type == 'database') {
262 if (isset($remember_template)) {
263 $GLOBALS['PMA_Config']->setCookie('pma_db_filename_template', $filename_template);
265 } else {
266 if (isset($remember_template)) {
267 $GLOBALS['PMA_Config']->setCookie('pma_table_filename_template', $filename_template);
270 $filename = PMA_expandUserString($filename_template);
272 // convert filename to iso-8859-1, it is safer
273 $filename = PMA_convert_string($charset, 'iso-8859-1', $filename);
275 // Grab basic dump extension and mime type
276 // Check if the user already added extension; get the substring where the extension would be if it was included
277 $extension_start_pos = strlen($filename) - strlen($export_list[$type]['extension']) - 1;
278 $user_extension = substr($filename, $extension_start_pos, strlen($filename));
279 $required_extension = "." . $export_list[$type]['extension'];
280 if(strtolower($user_extension) != $required_extension) {
281 $filename .= $required_extension;
283 $mime_type = $export_list[$type]['mime_type'];
285 // If dump is going to be compressed, set correct mime_type and add
286 // compression to extension
287 if ($compression == 'bzip') {
288 $filename .= '.bz2';
289 $mime_type = 'application/x-bzip2';
290 } elseif ($compression == 'gzip') {
291 $filename .= '.gz';
292 $mime_type = 'application/x-gzip';
293 } elseif ($compression == 'zip') {
294 $filename .= '.zip';
295 $mime_type = 'application/zip';
299 // Open file on server if needed
300 if ($save_on_server) {
301 $save_filename = PMA_userDir($cfg['SaveDir']) . preg_replace('@[/\\\\]@', '_', $filename);
302 unset($message);
303 if (file_exists($save_filename) && ((!$quick_export && empty($onserverover)) || ($quick_export && $_REQUEST['quick_export_onserverover'] != 'saveitover'))) {
304 $message = PMA_Message::error(__('File %s already exists on server, change filename or check overwrite option.'));
305 $message->addParam($save_filename);
306 } else {
307 if (is_file($save_filename) && !is_writable($save_filename)) {
308 $message = PMA_Message::error(__('The web server does not have permission to save the file %s.'));
309 $message->addParam($save_filename);
310 } else {
311 if (!$file_handle = @fopen($save_filename, 'w')) {
312 $message = PMA_Message::error(__('The web server does not have permission to save the file %s.'));
313 $message->addParam($save_filename);
317 if (isset($message)) {
318 require_once './libraries/header.inc.php';
319 if ($export_type == 'server') {
320 $active_page = 'server_export.php';
321 require './server_export.php';
322 } elseif ($export_type == 'database') {
323 $active_page = 'db_export.php';
324 require './db_export.php';
325 } else {
326 $active_page = 'tbl_export.php';
327 require './tbl_export.php';
329 exit();
334 * Send headers depending on whether the user chose to download a dump file
335 * or not
337 if (!$save_on_server) {
338 if ($asfile) {
339 // Download
340 // (avoid rewriting data containing HTML with anchors and forms;
341 // this was reported to happen under Plesk)
342 @ini_set('url_rewriter.tags','');
344 header('Content-Type: ' . $mime_type);
345 header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
346 // Tested behavior of
347 // IE 5.50.4807.2300
348 // IE 6.0.2800.1106 (small glitch, asks twice when I click Open)
349 // IE 6.0.2900.2180
350 // Firefox 1.0.6
351 // in http and https
352 header('Content-Disposition: attachment; filename="' . $filename . '"');
353 if (PMA_USR_BROWSER_AGENT == 'IE') {
354 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
355 header('Pragma: public');
356 } else {
357 header('Pragma: no-cache');
358 // test case: exporting a database into a .gz file with Safari
359 // would produce files not having the current time
360 // (added this header for Safari but should not harm other browsers)
361 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
363 } else {
364 // HTML
365 if ($export_type == 'database') {
366 $num_tables = count($tables);
367 if ($num_tables == 0) {
368 $message = PMA_Message::error(__('No tables found in database.'));
369 require_once './libraries/header.inc.php';
370 $active_page = 'db_export.php';
371 require './db_export.php';
372 exit();
375 $backup_cfgServer = $cfg['Server'];
376 require_once './libraries/header.inc.php';
377 $cfg['Server'] = $backup_cfgServer;
378 unset($backup_cfgServer);
379 echo "\n" . '<div align="' . $cell_align_left . '">' . "\n";
380 //echo ' <pre>' . "\n";
383 * Displays a back button with all the $_REQUEST data in the URL (store in a variable to also display after the textarea)
385 $back_button = '<p>[ <a href="';
386 if ($export_type == 'server') {
387 $back_button .= 'server_export.php?' . PMA_generate_common_url();
388 } elseif ($export_type == 'database') {
389 $back_button .= 'db_export.php?' . PMA_generate_common_url($db);
390 } else {
391 $back_button .= 'tbl_export.php?' . PMA_generate_common_url($db, $table);
394 // Convert the multiple select elements from an array to a string
395 if($export_type == 'server' && isset($_REQUEST['db_select'])) {
396 $_REQUEST['db_select'] = implode(",", $_REQUEST['db_select']);
397 } elseif($export_type == 'database' && isset($_REQUEST['table_select'])) {
398 $_REQUEST['table_select'] = implode(",", $_REQUEST['table_select']);
401 foreach($_REQUEST as $name => $value) {
402 $back_button .= '&' . urlencode($name) . '=' . urlencode($value);
404 $back_button .= '&repopulate=1">Back</a> ]</p>';
406 echo $back_button;
407 echo ' <form name="nofunction">' . "\n"
408 // remove auto-select for now: there is no way to select
409 // only a part of the text; anyway, it should obey
410 // $cfg['TextareaAutoSelect']
411 //. ' <textarea name="sqldump" cols="50" rows="30" onclick="this.select();" id="textSQLDUMP" wrap="OFF">' . "\n";
412 . ' <textarea name="sqldump" cols="50" rows="30" id="textSQLDUMP" wrap="OFF">' . "\n";
413 } // end download
416 // Fake loop just to allow skip of remain of this code by break, I'd really
417 // need exceptions here :-)
418 do {
420 // Add possibly some comments to export
421 if (!PMA_exportHeader()) {
422 break;
425 // Will we need relation & co. setup?
426 $do_relation = isset($GLOBALS[$what . '_relation']);
427 $do_comments = isset($GLOBALS[$what . '_include_comments']);
428 $do_mime = isset($GLOBALS[$what . '_mime']);
429 if ($do_relation || $do_comments || $do_mime) {
430 $cfgRelation = PMA_getRelationsParam();
432 if ($do_mime) {
433 require_once './libraries/transformations.lib.php';
436 // Include dates in export?
437 $do_dates = isset($GLOBALS[$what . '_dates']);
440 * Builds the dump
442 // Gets the number of tables if a dump of a database has been required
443 if ($export_type == 'server') {
444 if (isset($db_select)) {
445 $tmp_select = implode($db_select, '|');
446 $tmp_select = '|' . $tmp_select . '|';
448 // Walk over databases
449 foreach ($GLOBALS['pma']->databases as $current_db) {
450 if ((isset($tmp_select) && strpos(' ' . $tmp_select, '|' . $current_db . '|'))
451 || !isset($tmp_select)) {
452 if (!PMA_exportDBHeader($current_db)) {
453 break 2;
455 if (!PMA_exportDBCreate($current_db)) {
456 break 2;
458 $tables = PMA_DBI_get_tables($current_db);
459 $views = array();
460 foreach ($tables as $table) {
461 // if this is a view, collect it for later; views must be exported
462 // after the tables
463 $is_view = PMA_Table::isView($current_db, $table);
464 if ($is_view) {
465 $views[] = $table;
467 if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
468 // for a view, export a stand-in definition of the table
469 // to resolve view dependencies
470 if (!PMA_exportStructure($current_db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates, $is_view ? 'stand_in' : 'create_table', $export_type)) {
471 break 3;
474 // if this is a view or a merge table, don't export data
475 if (($GLOBALS[$what . '_structure_or_data'] == 'data' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') && !($is_view || PMA_Table::isMerge($current_db, $table))) {
476 $local_query = 'SELECT * FROM ' . PMA_backquote($current_db) . '.' . PMA_backquote($table);
477 if (!PMA_exportData($current_db, $table, $crlf, $err_url, $local_query)) {
478 break 3;
481 // now export the triggers (needs to be done after the data because
482 // triggers can modify already imported tables)
483 if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
484 if (!PMA_exportStructure($current_db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates, 'triggers', $export_type)) {
485 break 2;
489 foreach($views as $view) {
490 // no data export for a view
491 if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
492 if (!PMA_exportStructure($current_db, $view, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates, 'create_view', $export_type)) {
493 break 3;
497 if (!PMA_exportDBFooter($current_db)) {
498 break 2;
502 } elseif ($export_type == 'database') {
503 if (!PMA_exportDBHeader($db)) {
504 break;
506 $i = 0;
507 $views = array();
508 // $tables contains the choices from the user (via $table_select)
509 foreach ($tables as $table) {
510 // if this is a view, collect it for later; views must be exported after
511 // the tables
512 $is_view = PMA_Table::isView($db, $table);
513 if ($is_view) {
514 $views[] = $table;
516 if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
517 // for a view, export a stand-in definition of the table
518 // to resolve view dependencies
519 if (!PMA_exportStructure($db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates, $is_view ? 'stand_in' : 'create_table', $export_type)) {
520 break 2;
523 // if this is a view or a merge table, don't export data
524 if (($GLOBALS[$what . '_structure_or_data'] == 'data' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') && !($is_view || PMA_Table::isMerge($db, $table))) {
525 $local_query = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
526 if (!PMA_exportData($db, $table, $crlf, $err_url, $local_query)) {
527 break 2;
530 // now export the triggers (needs to be done after the data because
531 // triggers can modify already imported tables)
532 if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
533 if (!PMA_exportStructure($db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates, 'triggers', $export_type)) {
534 break 2;
538 foreach ($views as $view) {
539 // no data export for a view
540 if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
541 if (!PMA_exportStructure($db, $view, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates, 'create_view', $export_type)) {
542 break 2;
547 if (!PMA_exportDBFooter($db)) {
548 break;
550 } else {
551 if (!PMA_exportDBHeader($db)) {
552 break;
554 // We export just one table
555 // $allrows comes from the form when "Dump all rows" has been selected
556 if ($allrows == '0' && $limit_to > 0 && $limit_from >= 0) {
557 $add_query = ' LIMIT '
558 . (($limit_from > 0) ? $limit_from . ', ' : '')
559 . $limit_to;
560 } else {
561 $add_query = '';
564 $is_view = PMA_Table::isView($db, $table);
565 if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
566 if (!PMA_exportStructure($db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates, $is_view ? 'create_view' : 'create_table', $export_type)) {
567 break;
570 // If this is an export of a single view, we have to export data;
571 // for example, a PDF report
572 // if it is a merge table, no data is exported
573 if (($GLOBALS[$what . '_structure_or_data'] == 'data' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') && ! PMA_Table::isMerge($db, $table)) {
574 if (!empty($sql_query)) {
575 // only preg_replace if needed
576 if (!empty($add_query)) {
577 // remove trailing semicolon before adding a LIMIT
578 $sql_query = preg_replace('%;\s*$%', '', $sql_query);
580 $local_query = $sql_query . $add_query;
581 PMA_DBI_select_db($db);
582 } else {
583 $local_query = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . $add_query;
585 if (!PMA_exportData($db, $table, $crlf, $err_url, $local_query)) {
586 break;
589 // now export the triggers (needs to be done after the data because
590 // triggers can modify already imported tables)
591 if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
592 if (!PMA_exportStructure($db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates, 'triggers', $export_type)) {
593 break 2;
596 if (!PMA_exportDBFooter($db)) {
597 break;
600 if (!PMA_exportFooter()) {
601 break;
604 } while (false);
605 // End of fake loop
607 if ($save_on_server && isset($message)) {
608 require_once './libraries/header.inc.php';
609 if ($export_type == 'server') {
610 $active_page = 'server_export.php';
611 require './server_export.php';
612 } elseif ($export_type == 'database') {
613 $active_page = 'db_export.php';
614 require './db_export.php';
615 } else {
616 $active_page = 'tbl_export.php';
617 require './tbl_export.php';
619 exit();
623 * Send the dump as a file...
625 if (!empty($asfile)) {
626 // Convert the charset if required.
627 if ($output_charset_conversion) {
628 $dump_buffer = PMA_convert_string($GLOBALS['charset'], $GLOBALS['charset_of_file'], $dump_buffer);
631 // Do the compression
632 // 1. as a zipped file
633 if ($compression == 'zip') {
634 if (@function_exists('gzcompress')) {
635 $zipfile = new zipfile();
636 $zipfile -> addFile($dump_buffer, substr($filename, 0, -4));
637 $dump_buffer = $zipfile -> file();
640 // 2. as a bzipped file
641 elseif ($compression == 'bzip') {
642 if (@function_exists('bzcompress')) {
643 $dump_buffer = bzcompress($dump_buffer);
646 // 3. as a gzipped file
647 elseif ($compression == 'gzip') {
648 if (@function_exists('gzencode') && !@ini_get('zlib.output_compression')) {
649 // without the optional parameter level because it bug
650 $dump_buffer = gzencode($dump_buffer);
654 /* If ve saved on server, we have to close file now */
655 if ($save_on_server) {
656 $write_result = @fwrite($file_handle, $dump_buffer);
657 fclose($file_handle);
658 if (strlen($dump_buffer) !=0 && (!$write_result || ($write_result != strlen($dump_buffer)))) {
659 $message = new PMA_Message(__('Insufficient space to save the file %s.'), PMA_Message::ERROR, $save_filename);
660 } else {
661 $message = new PMA_Message(__('Dump has been saved to file %s.'), PMA_Message::SUCCESS, $save_filename);
664 require_once './libraries/header.inc.php';
665 if ($export_type == 'server') {
666 $active_page = 'server_export.php';
667 require_once './server_export.php';
668 } elseif ($export_type == 'database') {
669 $active_page = 'db_export.php';
670 require_once './db_export.php';
671 } else {
672 $active_page = 'tbl_export.php';
673 require_once './tbl_export.php';
675 exit();
676 } else {
677 echo $dump_buffer;
681 * Displays the dump...
683 else {
685 * Close the html tags and add the footers in dump is displayed on screen
687 echo '</textarea>' . "\n"
688 . ' </form>' . "\n";
689 echo $back_button;
691 echo "\n";
692 echo '</div>' . "\n";
693 echo "\n";
695 <script type="text/javascript">
696 //<![CDATA[
697 var bodyWidth=null; var bodyHeight=null;
698 if (document.getElementById('textSQLDUMP')) {
699 bodyWidth = self.innerWidth;
700 bodyHeight = self.innerHeight;
701 if (!bodyWidth && !bodyHeight) {
702 if (document.compatMode && document.compatMode == "BackCompat") {
703 bodyWidth = document.body.clientWidth;
704 bodyHeight = document.body.clientHeight;
705 } else if (document.compatMode && document.compatMode == "CSS1Compat") {
706 bodyWidth = document.documentElement.clientWidth;
707 bodyHeight = document.documentElement.clientHeight;
710 document.getElementById('textSQLDUMP').style.width=(bodyWidth-50) + 'px';
711 document.getElementById('textSQLDUMP').style.height=(bodyHeight-100) + 'px';
713 //]]>
714 </script>
715 <?php
716 require './libraries/footer.inc.php';
717 } // end if