Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/admin/tool/dbtransfer/locallib.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00016 
00026 defined('MOODLE_INTERNAL') || die;
00027 /*
00028 
00029 TODO:
00030   - exporting to server file >2GB fails in 32bit operating systems - needs warning
00031   - we may run out of disk space exporting to server file - we must verify the file is not truncated; read from the end of file?
00032   - when sending file >4GB - FAT32 limit, Apache limit, browser limit - needs warning
00033   - there must be some form of progress bar during export, transfer - new tracking class could be passed around
00034   - command line operation - could work around some 2G/4G limits in PHP; useful for cron full backups
00035   - by default allow exporting into empty database only (no tables with the same prefix yet)
00036   - all dangerous operation (like deleting of all data) should be confirmed by key found in special file in dataroot
00037     (user would need file access to dataroot which might prevent various "accidents")
00038   - implement "Export/import running" notification in lib/setup.php (similar to new upgrade flag in config table)
00039   - gzip compression when storing xml file - the xml is very verbose and full of repeated tags (zip is not suitable here at all)
00040     this could help us keep the files below 2G (expected ratio is > 10:1)
00041 
00042 */
00043 
00044 require_once($CFG->libdir.'/adminlib.php');
00045 require_once($CFG->libdir.'/dtllib.php');
00046 
00047 
00048 function dbtransfer_export_xml_database($description, $mdb) {
00049     @set_time_limit(0);
00050 
00051     session_get_instance()->write_close(); // release session
00052 
00053     header('Content-Type: application/xhtml+xml; charset=utf-8');
00054     header('Content-Disposition: attachment; filename=database.xml');
00055     header('Expires: 0');
00056     header('Cache-Control: must-revalidate,post-check=0,pre-check=0');
00057     header('Pragma: public');
00058 
00059     while(@ob_flush());
00060 
00061     $var = new file_xml_database_exporter('php://output', $mdb);
00062     $var->export_database($description);
00063 
00064     // no more output
00065     die;
00066 }
00067 
00068 
00069 function dbtransfer_transfer_database($sourcedb, $targetdb, $feedback = null) {
00070     @set_time_limit(0);
00071 
00072     session_get_instance()->write_close(); // release session
00073 
00074     $var = new database_mover($sourcedb, $targetdb, true, $feedback);
00075     $var->export_database(null);
00076 }
 All Data Structures Namespaces Files Functions Variables Enumerations