初始化
This commit is contained in:
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
$activeMenu = 'databaseBackup';
|
||||
include APP_PATH . 'app/views/layouts/admin_header.php';
|
||||
?>
|
||||
|
||||
<?php if (!empty($message)): ?>
|
||||
<div class="alert alert-<?php echo $messageType; ?> alert-dismissible">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
<h4><i class="icon fa <?php echo $messageType === 'success' ? 'fa-check' : ($messageType === 'danger' ? 'fa-ban' : 'fa-warning'); ?>"></i> 操作结果</h4>
|
||||
<?php echo nl2br(htmlspecialchars($message)); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="row">
|
||||
<!-- 备份操作区 -->
|
||||
<div class="col-md-5">
|
||||
<div class="box box-success">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title"><i class="fa fa-cloud-download"></i> 创建备份</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<p class="text-muted">将当前数据库导出为 SQL 文件,保存到服务器 <code>backups/</code> 目录。</p>
|
||||
<p>数据库:<strong><?php echo htmlspecialchars(DB_NAME); ?></strong></p>
|
||||
<p>主机:<strong><?php echo htmlspecialchars(DB_HOST); ?></strong></p>
|
||||
<form method="post" onsubmit="return confirm('确定要创建数据库备份吗?');">
|
||||
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrfToken); ?>">
|
||||
<input type="hidden" name="action" value="backup">
|
||||
<button type="submit" class="btn btn-success btn-lg btn-block">
|
||||
<i class="fa fa-database"></i> 立即备份数据库
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="box-footer text-muted">
|
||||
<small><i class="fa fa-info-circle"></i> 备份将包含所有表结构和数据(排除 jp_ 前缀的表)</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="box box-default">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title"><i class="fa fa-info-circle"></i> 说明</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<ul>
|
||||
<li><strong>备份</strong>:将数据库完整导出为 .sql 文件保存到服务器本地</li>
|
||||
<li><strong>恢复</strong>:选择一个备份文件,将其数据恢复到当前数据库</li>
|
||||
<li><strong>下载</strong>:将备份文件下载到本地电脑保存</li>
|
||||
<li><strong>删除</strong>:删除服务器上的备份文件</li>
|
||||
</ul>
|
||||
<div class="callout callout-warning">
|
||||
<h4><i class="fa fa-warning"></i> 注意</h4>
|
||||
<p>恢复操作会<strong>覆盖当前数据库</strong>中已存在的同名表!请在恢复前确认已做好最新备份。</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 备份文件列表 -->
|
||||
<div class="col-md-7">
|
||||
<div class="box box-primary">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title"><i class="fa fa-files-o"></i> 备份文件列表</h3>
|
||||
<div class="box-tools">
|
||||
<span class="badge bg-blue">共 <?php echo count($backupFiles); ?> 个备份</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-body table-responsive no-padding">
|
||||
<?php if (empty($backupFiles)): ?>
|
||||
<div class="text-center" style="padding:40px;">
|
||||
<i class="fa fa-inbox" style="font-size:48px; color:#ddd;"></i>
|
||||
<p class="text-muted" style="margin-top:10px;">暂无备份文件,请先创建备份</p>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>文件名</th>
|
||||
<th>大小</th>
|
||||
<th>备份时间</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($backupFiles as $file): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<i class="fa fa-file-code-o text-primary"></i>
|
||||
<code><?php echo htmlspecialchars($file['name']); ?></code>
|
||||
</td>
|
||||
<td><span class="badge bg-light-blue"><?php echo $file['size']; ?></span></td>
|
||||
<td><?php echo $file['time']; ?></td>
|
||||
<td>
|
||||
<!-- 恢复 -->
|
||||
<form method="post" style="display:inline;" onsubmit="return confirm('确定要恢复此备份吗?\n\n⚠ 此操作会覆盖当前数据库中的数据!\n建议先创建最新备份。');">
|
||||
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrfToken); ?>">
|
||||
<input type="hidden" name="action" value="restore">
|
||||
<input type="hidden" name="file" value="<?php echo htmlspecialchars($file['name']); ?>">
|
||||
<button type="submit" class="btn btn-sm btn-warning" title="恢复此备份">
|
||||
<i class="fa fa-cloud-upload"></i> 恢复
|
||||
</button>
|
||||
</form>
|
||||
<!-- 下载 -->
|
||||
<form method="post" style="display:inline;">
|
||||
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrfToken); ?>">
|
||||
<input type="hidden" name="action" value="download">
|
||||
<input type="hidden" name="file" value="<?php echo htmlspecialchars($file['name']); ?>">
|
||||
<button type="submit" class="btn btn-sm btn-primary" title="下载到本地">
|
||||
<i class="fa fa-download"></i> 下载
|
||||
</button>
|
||||
</form>
|
||||
<!-- 删除 -->
|
||||
<form method="post" style="display:inline;" onsubmit="return confirm('确定要删除备份文件 <?php echo htmlspecialchars($file['name']); ?> 吗?');">
|
||||
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrfToken); ?>">
|
||||
<input type="hidden" name="action" value="delete">
|
||||
<input type="hidden" name="file" value="<?php echo htmlspecialchars($file['name']); ?>">
|
||||
<button type="submit" class="btn btn-sm btn-danger" title="删除备份文件">
|
||||
<i class="fa fa-trash"></i> 删除
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include APP_PATH . 'app/views/layouts/admin_footer.php'; ?>
|
||||
Reference in New Issue
Block a user