MDL-25973 add missing charset
[moodle.git] / admin / dbtransfer / lib.php
CommitLineData
11b749ca 1<?php
3b49f849 2
3/*
4
5TODO:
6 - exporting to server file >2GB fails in 32bit operating systems - needs warning
7 - we may run out of disk space exporting to srever file - we must verify the file is not truncated; read from the end of file?
8 - when sending file >4GB - FAT32 limit, Apache limit, browser limit - needs warning
9 - there must be some form of progress bar during export, transfer - new tracking class could be passed around
10 - command line operation - could work around some 2G/4G limits in PHP; useful for cron full backups
11 - by default allow exporting into empty database only (no tables with the same prefix yet)
12 - all dangerous operation (like deleting of all data) should be confirmed by key found in special file in dataroot
13 (user would need file access to dataroot which might prevent various "accidents")
14 - implement "Export/import running" notification in lib/setup.php (similar to new upgrade flag in config table)
15 - gzip compression when storing xml file - the xml is very verbose and full of repeated tags (zip is not suitable here at all)
16 this could help us keep the files bellow 2G (expected ratio is > 10:1)
17
18*/
19
20require_once($CFG->libdir.'/adminlib.php');
21require_once($CFG->libdir.'/dtllib.php');
22
23
24function dbtransfer_export_xml_database($description, $mdb) {
25 @set_time_limit(0);
26
56949c17 27 session_get_instance()->write_close(); // release session
3b49f849 28
8a7703ce 29 header('Content-Type: application/xhtml+xml; charset=utf-8');
3b49f849 30 header('Content-Disposition: attachment; filename=database.xml');
31 header('Expires: 0');
32 header('Cache-Control: must-revalidate,post-check=0,pre-check=0');
33 header('Pragma: public');
34
35 while(@ob_flush());
36
37 $var = new file_xml_database_exporter('php://output', $mdb);
38 $var->export_database($description);
39
40 // no more output
41 die;
42}
43
44
e69b06ef 45function dbtransfer_transfer_database($sourcedb, $targetdb, $feedback = null) {
3b49f849 46 @set_time_limit(0);
47
56949c17 48 session_get_instance()->write_close(); // release session
3b49f849 49
e69b06ef 50 $var = new database_mover($sourcedb, $targetdb, true, $feedback);
3b49f849 51 $var->export_database(null);
52}