我们在首页控制器Index重定向到了Bak控制器中,即数据库管理所有操作方法。备份的数据库放在根目录文件夹databak中,接着引入MySQLReback类。
$DataDir = "databak/"; mkdir($DataDir); import("Common.Org.MySQLReback"); $mr = new MySQLReback($config); $mr->setDBName(C('DB_NAME'));
下载:
if ($_GET['Action'] == 'download') { function DownloadFile($fileName) { ob_end_clean(); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Length: ' . filesize($fileName)); header('Content-Disposition: attachment; filename=' . basename($fileName)); readfile($fileName); } DownloadFile($DataDir . $_GET['file']); exit(); } }