-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBackups.php
73 lines (67 loc) · 3.29 KB
/
Backups.php
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php $name = "OneCircle";
$db = Typecho_Db::get();
$sjdq = $db->fetchRow($db->select()->from('table.options')->where('name = ?', 'plugin:' . $name));
$ysj = $sjdq['value'];
if (isset($_POST['type'])) {
/* 备份数据 */
if ($_POST["type"] == "备份插件") {
if ($db->fetchRow($db->select()->from('table.options')->where('name = ?', 'plugin:' . $name . 'bf'))) {
$update = $db->update('table.options')->rows(array('value' => $ysj))->where('name = ?', 'plugin:' . $name . 'bf');
$updateRows = $db->query($update); ?>
<script>
alert("备份更新成功!");
window.location.href = '<?php Helper::options()->adminUrl('options-plugin.php?config='.$name); ?>'
</script>
<?php } else {
if ($ysj) {
$insert = $db->insert('table.options')->rows(array('name' => 'plugin:' . $name . 'bf', 'user' => '0', 'value' => $ysj));
$insertId = $db->query($insert); ?>
<script>
alert("备份成功!");
window.location.href = '<?php Helper::options()->adminUrl('options-plugin.php?config='.$name); ?>'
</script>
<?php }
}
}
/* 还原备份 */
if ($_POST["type"] == "还原备份") {
if ($db->fetchRow($db->select()->from('table.options')->where('name = ?', 'plugin:' . $name . 'bf'))) {
$sjdub = $db->fetchRow($db->select()->from('table.options')->where('name = ?', 'plugin:' . $name . 'bf'));
$bsj = $sjdub['value'];
$update = $db->update('table.options')->rows(array('value' => $bsj))->where('name = ?', 'plugin:' . $name);
$updateRows = $db->query($update); ?>
<script>
alert("还原成功!");
window.location.href = '<?php Helper::options()->adminUrl('options-plugin.php?config='.$name); ?>'
</script>
<?php } else { ?>
<script>
alert("未备份过数据,无法恢复!");
window.location.href = '<?php Helper::options()->adminUrl('options-plugin.php?config='.$name); ?>'
</script>
<?php } ?>
<?php } ?>
<!-- 删除备份 -->
<?php if ($_POST["type"] == "删除备份") {
if ($db->fetchRow($db->select()->from('table.options')->where('name = ?', 'plugin:' . $name . 'bf'))) {
$delete = $db->delete('table.options')->where('name = ?', 'plugin:' . $name . 'bf');
$deletedRows = $db->query($delete); ?>
<script>
alert("删除成功");
window.location.href = '<?php Helper::options()->adminUrl('options-plugin.php?config='.$name); ?>'
</script>
<?php } else { ?>
<script>
alert("没有备份内容,无法删除!");
window.location.href = '<?php Helper::options()->adminUrl('options-plugin.php?config='.$name); ?>'
</script>
<?php } ?>
<?php } ?>
<?php } ?>
<?php
echo '
<form class="j-backup" action="?config=OneCircle" method="post">
<input type="submit" name="type" value="备份插件" />
<input type="submit" name="type" value="还原备份" />
<input type="submit" name="type" value="删除备份" />
</form>';