BakController.php
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace app\admin\controller;
use cmf\controller\AdminBaseController;
class BakController extends AdminBaseController {
public function index(){
$type = $this->request->param('tp');
$name = $this->request->param('name');
$sql=new \org\Baksql(config('database'));
switch ($type)
{
case "backup": //备份
$ret=$sql->backup();
if($ret['code']=1){
$this->success($ret['msg']);
}else{
$this->error($ret['msg']);
}
break;
case "dowonload": //下载
$sql->downloadFile($name);
break;
case "restore": //还原
$ret= $sql->restore($name);
if($ret['code']=1){
$this->success($ret['msg']);
}else{
$this->error($ret['msg']);
}
break;
case "del": //删除
$ret= $sql->delfilename($name);
if($ret['code']=1){
$this->success($ret['msg']);
}else{
$this->error($ret['msg']);
}
break;
default: //获取备份文件列表
return $this->fetch("index",["list"=>$sql->get_filelist()]);
}
}
}
?>