-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsystem_restore.php
More file actions
92 lines (90 loc) · 2.64 KB
/
system_restore.php
File metadata and controls
92 lines (90 loc) · 2.64 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
91
92
<?php
require(dirname(__FILE__)."/include/config_base.php");
require(dirname(__FILE__)."/include/config_rglobals.php");
require_once(dirname(__FILE__)."/include/checklogin.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'){
if($filename==''){
showmsg("请输入正确的备份文件名称!",-1);
}
$fp = fopen("/backup/".$filename,"r");
//创建数据表和写入数据
$query = "";
while(!feof($fp))
{
$line = trim(fgets($fp,1024));
if(preg_match("/;$/",$line)){
$query .= $line;
$query = str_replace('#@__',$dbprefix,$query);
mysqli_query($conn, $query);
$query='';
}else if(!preg_match("/^(//|--)/",$line)){
$query .= $line;
}
}
fclose($fp);
$sysquerys = explode(';',$admindatas);
foreach($sysquerys as $query){
if(trim($query)!='') mysqli_query($conn, str_replace('#@__',$dbprefix,$query));
}
mysqli_close($conn);
echo "<table id='table_border' width='100%'><tr><td id='row_style'> 备份文件".$filename."成功还原!</td></tr></table>";
}
else
{
?>
<table width="100%" cellspacing="0" cellpadding="0" border="0" id="table_border">
<form action="system_restore.php?action=save" method="post">
<tr>
<td id="row_style">备份文件名:</td>
<td> <input type="text" name="filename"> (备份文件位于/backup/目录下的.sql文件.)
</tr>
<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>