Files
OMS/app/desktop/controller/backup.php
2025-12-28 23:13:25 +08:00

65 lines
2.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* Copyright © ShopeX http://www.shopex.cn. All rights reserved.
* See LICENSE file for license details.
*/
class desktop_ctl_backup extends desktop_controller{
function index(){
$this->path[] = array('text'=>app::get('desktop')->_('数据备份'));
if($time = app::get('shopex')->getConf("system.last_backup")){
$this->pagedata['time'] = date('Y-m-d H:i:s',$time);
}
$this->pagedata['backup'] = 'current';
kernel::single("desktop_ctl_data")->index();
$this->page('system/backup/backup.html');
}
function backup_sdf(){
ini_set("max_exection_time", 0);
header("Content-type:text/html;charset=utf-8");
$params['dirname'] = ($_GET["dirname"]=="") ? date("YmdHis", time()) : $_GET["dirname"];
$params['appname'] = $_GET['appname'];
#$params['cols'] = $_GET['cols'] ? $_GET['cols'] : 0;
#$params['model'] = $_GET['model'] ? $_GET['model'] : '';
#$params['startid'] = $_GET['startid'] ? $_GET['startid'] : 0;
$oBackup = kernel::single('desktop_system_backup');
if(!$oBackup->start_backup_sdf($params,$nexturl)){
echo '{message:"'.app::get('desktop')->_('正在备份应用:').($params['appname']).'",
nexturl:"'.$nexturl.'"}';
}
else{
app::get('shopex')->setConf("system.last_backup", time(), true);
echo '{success:"'.app::get('desktop')->_('备份完成').'",nexturl:"index.php?app=desktop&ctl=backup&act=getFile&file=multibak_'.$params['dirname'].'.zip"}';
}
}
/**
* 获取File
* @return mixed 返回结果
*/
public function getFile() {
$file = $_GET['file'];
if($file && preg_match('/(\..\/){1,}/', $file)){
header("Content-type: text/html; charset=utf-8");
echo app::get('desktop')->_('非法操作');exit;;
}
kernel::single('desktop_system_backup')->download($file);
}
}