-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsystem_backup.php
More file actions
90 lines (86 loc) · 2.59 KB
/
system_backup.php
File metadata and controls
90 lines (86 loc) · 2.59 KB
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
<?php
require(dirname(__FILE__)."/include/config_base.php");
require(dirname(__FILE__)."/include/config_rglobals.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/2019/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<link href="style/main.css" rel="stylesheet" type="text/css" />
<title><?php echo $cfs_softname;?>数据备份</title>
</head>
<body>
<table width="100%" border="0" id="table_style_all" cellpadding="0" cellspacing="0">
<tr>
<td id="table_style" class="l_t"> </td>
<td> </td>
<td id="table_style" class="r_t"> </td>
</tr>
<tr>
<td> </td>
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="2">
<tr>
<td><strong> 数据备份</strong></td>
</tr>
<tr>
<td bgcolor="#FFFFFF">
<?php
if($action=='save'){
$q1=mysqli_query("show tables");
while($t=mysql_fetch_array($q1)){
$table=$t[0];
$q2=mysqli_query("show create table `$table`");
$sql=mysqli_fetch_array($q2);
$mysql.=$sql['Create Table'].";\r\n\r\n";#DDL
$q3=mysqli_query("select * from `$table`");
while($data=mysql_fetch_assoc($q3))
{
$keys=array_keys($data);
$keys=array_map('addslashes',$keys);
$keys=join('`,`',$keys);
$keys="`".$keys."`";
$vals=array_values($data);
$vals=array_map('addslashes',$vals);
$vals=join("','",$vals);
$vals="'".$vals."'";
$mysql.="insert into `$table`($keys) values($vals);\r\n";
}
$mysql.="\r\n";
}
$filename="data/".date('Ymdhms')."_".$cfg_dbname.".sql"; //文件名为当天的日期
$fp = fopen($filename,'w');
fputs($fp,$mysql);
fclose($fp);
echo "<table id='table_border' width='100%'><tr id='row_style'><td> 数据备份成功,生成备份文件".$filename."</td></tr></table>";
}
else
{
?>
<table width="100%" cellspacing="0" cellpadding="0" border="0" id="table_border">
<form action="system_backup.php?action=save" method="post">
<tr>
<td id="row_style"> </td>
<td> <input type="submit" name="submit" value=" 备份所有数据 "></td>
</tr></form>
</table>
</td>
</tr>
</table>
<?php
}
?>
</td>
<td> </td>
</tr>
<tr>
<td id="table_style" class="l_b"> </td>
<td> </td>
<td id="table_style" class="r_b"> </td>
</tr>
</table>
<?php
copyright();
?>
</body>
</html>