* Refator backup.

This commit is contained in:
chaideqing
2023-08-21 02:02:25 +00:00
parent 08cb72394b
commit 71efce1347
9 changed files with 61 additions and 24 deletions
+20 -5
View File
@@ -69,17 +69,32 @@ class backup extends control
}
krsort($backups);
$diskSapce = $this->backup->checkDiskSpace($this->backupPath);
$alertTips = sprintf($this->lang->backup->insufficientDisk, round($diskSapce / (1024 * 1024 * 1024), 2));
$this->view->diskSapce = $diskSapce;
$this->view->alertTips = $alertTips;
$this->view->title = $this->lang->backup->common;
$this->view->position[] = $this->lang->backup->common;
$this->view->backups = $backups;
$this->display();
}
/**
* Ajax get disk space.
*
* @access public
* @return void
*/
public function ajaxGetkDiskSpace()
{
set_time_limit(0);
session_write_close();
$diskSapce = $this->backup->getkDiskSpace($this->backupPath);
$diskSapce = explode(',', $diskSapce);
$space = new stdclass();
$space->freeSpace = $diskSapce[0];
$space->needSpace = $diskSapce[1];
echo json_encode($space);
}
/**
* Backup.
*
+21 -7
View File
@@ -2,14 +2,28 @@ $(function()
{
$('.backup').click(function()
{
if(diskSapce)
var that = this;
$(that).toggleClass('loading');
$(that).text(getSpaceLoading);
link = createLink('backup', 'ajaxGetkDiskSpace');
$.get(link, function(data)
{
$('#spaceConfirm').modal('show', 'center');
}
else
{
backupData();
}
$(that).toggleClass('loading');
$(that).text(startBackup);
if(data)
{
if(data.needSpace > data.freeSpace)
{
alertTips = alertTips.replace('NEED_SPACE', (data.needSpace/1024/1024).toFixed(2));
$('#spaceConfirm').find('p').text(alertTips);
$('#spaceConfirm').modal('show', 'center');
}
else
{
backupData();
}
}
}, 'json');
});
$('.rmPHPHeader').click(function()
+2 -1
View File
@@ -36,9 +36,10 @@ $lang->backup->confirmRestore = 'Möchten Sie das Backup wiederherstellen?';
$lang->backup->holdDays = 'Behalten der letzen %s Tage der Backups';
$lang->backup->copiedFail = 'Copy failed files: ';
$lang->backup->restoreTip = 'Nur Dateien und Datenbanken können wiederhergestellt werden. Code kann manuell wieder hergestellt werden.';
$lang->backup->insufficientDisk = 'Disk space less than%.2fG, it may cause insufficient backup space or affect the use, please process it and try again.';
$lang->backup->insufficientDisk = 'Disk space less thanNEED_SPACEG, it may cause insufficient backup space or affect the use, please process it and try again.';
$lang->backup->ongoBackup = 'ongoing backup';
$lang->backup->cancelBackup = 'cancel backup';
$lang->backup->getSpaceLoading = 'Calculate backup space';
$lang->backup->success = new stdclass();
$lang->backup->success->backup = 'Erledigt!';
+2 -1
View File
@@ -36,9 +36,10 @@ $lang->backup->confirmRestore = 'Do you want to restore the backup?';
$lang->backup->holdDays = 'Hold last %s days of backup';
$lang->backup->copiedFail = 'Copy failed files: ';
$lang->backup->restoreTip = 'Only files and databases can be restored by clicking Restore. Code can be restored manually.';
$lang->backup->insufficientDisk = 'Disk space less than%.2fG, it may cause insufficient backup space or affect the use, please process it and try again.';
$lang->backup->insufficientDisk = 'Disk space less thanNEED_SPACEG, it may cause insufficient backup space or affect the use, please process it and try again.';
$lang->backup->ongoBackup = 'ongoing backup';
$lang->backup->cancelBackup = 'cancel backup';
$lang->backup->getSpaceLoading = 'Calculate backup space';
$lang->backup->success = new stdclass();
$lang->backup->success->backup = 'Done!';
+2 -1
View File
@@ -36,9 +36,10 @@ $lang->backup->confirmRestore = 'Voulez-vous restaurer la sauvegarde ?';
$lang->backup->holdDays = 'conserver les derniers %s jours de backup';
$lang->backup->copiedFail = 'Fichiers en échec de copie : ';
$lang->backup->restoreTip = 'Seulement les fichiers et les bases peuvent être restaurées en cliquant sur Restaurer. Le code doit être restauré manuellement.';
$lang->backup->insufficientDisk = 'Disk space less than%.2fG, it may cause insufficient backup space or affect the use, please process it and try again.';
$lang->backup->insufficientDisk = 'Disk space less thanNEED_SPACEG, it may cause insufficient backup space or affect the use, please process it and try again.';
$lang->backup->ongoBackup = 'ongoing backup';
$lang->backup->cancelBackup = 'cancel backup';
$lang->backup->getSpaceLoading = 'Calculate backup space';
$lang->backup->success = new stdclass();
$lang->backup->success->backup = 'Terminé avec succès !';
+2 -1
View File
@@ -33,9 +33,10 @@ $lang->backup->confirmRestore = 'Bạn có muốn khôi phục sao lưu này?'
$lang->backup->holdDays = 'Giữ ít nhất %s ngày sao lưu';
$lang->backup->copiedFail = 'Copy failed files: ';
$lang->backup->restoreTip = 'Chỉ tập tin và CSDL có thể được khôi phục bằng cách Click Khôi phục. Mã nguồn có thể khôi phục thủ công.';
$lang->backup->insufficientDisk = 'Không gian đĩa nhỏ hơn%.2fG, Nó có thể gây ra không đủ dung lượng sao lưu hoặc ảnh hưởng đến việc sử dụng, vui lòng xử lý và thử lại.';
$lang->backup->insufficientDisk = 'Không gian đĩa nhỏ hơnNEED_SPACEG, Nó có thể gây ra không đủ dung lượng sao lưu hoặc ảnh hưởng đến việc sử dụng, vui lòng xử lý và thử lại.';
$lang->backup->ongoBackup = 'tiếp tục sao lưu';
$lang->backup->cancelBackup = 'hủy sao lưu';
$lang->backup->getSpaceLoading = 'Tính toán không gian dự phòng';
$lang->backup->success = new stdclass();
$lang->backup->success->backup = 'Sao lưu hoàn thành!';
+2 -1
View File
@@ -36,9 +36,10 @@ $lang->backup->confirmRestore = '是否还原该备份?';
$lang->backup->holdDays = '备份保留最近 %s 天';
$lang->backup->copiedFail = '复制失败的文件:';
$lang->backup->restoreTip = '还原功能只还原附件和数据库,如果需要还原代码,可以手动还原。';
$lang->backup->insufficientDisk = '磁盘空间小于%.2fG,可能会导致备份空间不足或影响使用,请处理后再试。';
$lang->backup->insufficientDisk = '磁盘空间小于NEED_SPACEG,可能会导致备份空间不足或影响使用,请处理后再试。';
$lang->backup->ongoBackup = '继续备份';
$lang->backup->cancelBackup = '取消备份';
$lang->backup->getSpaceLoading = '正在计算备份空间';
$lang->backup->success = new stdclass();
$lang->backup->success->backup = '备份成功!';
+5 -4
View File
@@ -433,18 +433,19 @@ class backupModel extends model
}
/**
* Check disk space is enough.
* Get disk space.
*
* @param int $backupPath
* @access public
* @return int
*/
public function checkDiskSpace($backupPath)
public function getkDiskSpace($backupPath)
{
$nofile = strpos($this->config->backup->setting, 'nofile') !== false;
$diskFreeSpace = disk_free_space($backupPath);
$backFileSize = 0;
$zfile = $this->app->loadClass('zfile');
$backFileSize = 0;
if(!$nofile)
{
@@ -459,6 +460,6 @@ class backupModel extends model
->groupBy('TABLE_SCHEMA')
->fetch('size');
return ($diskFreeSpace - ($backFileSize + $backSqlSize) > 0) ? 0 : $backFileSize + $backSqlSize;
return $diskFreeSpace . ',' . ($backFileSize + $backSqlSize);
}
}
+5 -3
View File
@@ -31,7 +31,7 @@
if(common::hasPriv('backup', 'backup'))
{
$backupLink = helper::createLink('backup', 'backup', 'reload=yes');
echo html::commonButton("<i class='icon icon-copy'> </i>" . $lang->backup->backup, "data-link='{$backupLink}'", 'btn btn-primary backup');
echo html::commonButton("<i class='icon icon-copy'> </i>" . $lang->backup->backup, "data-link='{$backupLink}'", 'btn btn-primary backup load-indicator');
}
?>
</div>
@@ -120,7 +120,7 @@
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-body">
<p><?php echo $alertTips;?></p>
<p></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><?php echo $lang->backup->cancelBackup;?></button>
@@ -129,9 +129,11 @@
</div>
</div>
<?php js::set('backup', $lang->backup->common);?>
<?php js::set('diskSapce', $diskSapce);?>
<?php js::set('startBackup', $lang->backup->backup);?>
<?php js::set('getSpaceLoading', $lang->backup->getSpaceLoading);?>
<?php js::set('rmPHPHeader', $lang->backup->rmPHPHeader);?>
<?php js::set('confirmRestore', $lang->backup->confirmRestore);?>
<?php js::set('restore', $lang->backup->restore);?>
<?php js::set('backupTimeout', $lang->backup->error->timeout);?>
<?php js::set('alertTips', $lang->backup->insufficientDisk);?>
<?php include '../../common/view/footer.html.php';?>