-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackup.php
121 lines (118 loc) · 3.41 KB
/
backup.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php use Utils\Helper;
$name = "jasmine";
$db = Typecho_Db::get();
if (isset($_POST["type"])) {
if ($_POST["type"] == "备份设置") {
$value = $db->fetchRow(
$db
->select()
->from("table.options")
->where("name = ?", "theme:" . $name)
)["value"];
if (
$db->fetchRow(
$db
->select()
->from("table.options")
->where("name = ?", "theme:" . $name . "_backup")
)
) {
$db->query(
$db
->update("table.options")
->rows(["value" => $value])
->where("name = ?", "theme:" . $name . "_backup")
); ?>
<script>
alert("备份更新成功!");
window.location.href = '<?php Helper::options()->adminUrl("options-theme.php"); ?>'
</script>
<?php
} else {
?>
<?php if ($value) {
$db->query(
$db
->insert("table.options")
->rows(["name" => "theme:" . $name . "_backup", "user" => "0", "value" => $value])
); ?>
<script>
alert("备份成功!");
window.location.href = '<?php Helper::options()->adminUrl("options-theme.php"); ?>'
</script>
<?php
}
}
}
if ($_POST["type"] == "还原备份") {
if (
$db->fetchRow(
$db
->select()
->from("table.options")
->where("name = ?", "theme:" . $name . "_backup")
)
) {
$_value = $db->fetchRow(
$db
->select()
->from("table.options")
->where("name = ?", "theme:" . $name . "_backup")
)["value"];
$db->query(
$db
->update("table.options")
->rows(["value" => $_value])
->where("name = ?", "theme:" . $name)
);
?>
<script>
alert("还原成功!");
window.location.href = '<?php Helper::options()->adminUrl("options-theme.php"); ?>'
</script>
<?php
} else {
?>
<script>
alert("未备份过数据,无法恢复!");
window.location.href = '<?php Helper::options()->adminUrl("options-theme.php"); ?>'
</script>
<?php
} ?>
<?php
}
?>
<?php if ($_POST["type"] == "删除备份") {
if (
$db->fetchRow(
$db
->select()
->from("table.options")
->where("name = ?", "theme:" . $name . "_backup")
)
) {
$db->query($db->delete("table.options")->where("name = ?", "theme:" . $name . "_backup")); ?>
<script>
alert("删除成功");
window.location.href = '<?php Helper::options()->adminUrl("options-theme.php"); ?>'
</script>
<?php
} else {
?>
<script>
alert("没有备份内容,无法删除!");
window.location.href = '<?php Helper::options()->adminUrl("options-theme.php"); ?>'
</script>
<?php
} ?>
<?php
} ?>
<?php
}
?>
<?php echo '
<form class="backup" action="?Joe_backup" method="post">
<input type="submit" name="type" value="备份设置" />
<input type="submit" name="type" value="还原备份" />
<input type="submit" name="type" value="删除备份" />
</form>';