forked from poppyred/1.6.x
/
zarafa.dabatase.restore.php
executable file
·128 lines (101 loc) · 3.31 KB
/
zarafa.dabatase.restore.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
122
123
124
125
126
127
<?php
include_once('ressources/class.templates.inc');
include_once('ressources/class.ldap.inc');
include_once('ressources/class.users.menus.inc');
include_once('ressources/class.artica.inc');
include_once('ressources/class.mysql.inc');
include_once('ressources/class.ini.inc');
include_once('ressources/class.cyrus.inc');
include_once('ressources/class.cron.inc');
$users=new usersMenus();
if(!$users->AsPostfixAdministrator){
$tpl=new templates();
$error=$tpl->javascript_parse_text("{ERROR_NO_PRIVS}");
echo "alert('$error')";
die();
}
if(isset($_GET["popup"])){popup();exit;}
if(isset($_POST["restore-path"])){restorefrom();exit;}
if(isset($_POST["restore-logs"])){restorelogs();exit;}
js();
function js(){
header("content-type: application/x-javascript");
$page=CurrentPageName();
$tpl=new templates();
$title=$tpl->javascript_parse_text("{restore_from_backup}");
$html="YahooWin3('650','$page?popup=yes','$title')";
echo $html;
}
function popup(){
$page=CurrentPageName();
$tpl=new templates();
$t=time();
$warn_restore_articadb=$tpl->javascript_parse_text("{warn_restore_articadb}");
$html="
<div style='font-size:14px' class=explain>{zarafadb_restore_explain}</div>
<table style='width:99%' class=form>
<tr>
<td class=legend>{backup_file}:</td>
<td>". field_text("backup$t",null,"font-size:16px;width:210px")."</td>
<td>". button("{browse}","Loadjs('tree.php?target-form=backup$t')",13)."</td>
</tr>
<tr>
<td colspan=3 align='right'><hr>". button("{restore}","Restore$t()",18)."</td>
</tr>
</table>
<div id='start-$t'></div>
<script>
var x_Restore$t= function (obj) {
var tempvalue=obj.responseText;
if(tempvalue.length>3){alert(tempvalue);}
document.getElementById('start-$t').innerHTML='';
LoadAjax('start-$t','$page?logs-starter=yes&t=$t');
}
function Restore$t(){
var path=document.getElementById('backup$t').value;
if(!confirm('$warn_restore_articadb')){return;}
var XHR = new XHRConnection();
XHR.appendData('restore-path',path);
AnimateDiv('start-$t');
XHR.sendAndLoad('$page', 'POST',x_Restore$t);
}
var x_GetLogs$t= function (obj) {
var tempvalue=obj.responseText;
if(tempvalue.length>3){
document.getElementById('textToParseCats-$t').innerHTML=tempvalue;
}
if(!YahooWin3Open()){return;}
setTimeout(\"GetLogs$t()\",1000);
}
function GetLogs$t(){
if(!YahooWin3Open()){return;}
var XHR = new XHRConnection();
XHR.appendData('restore-logs','yes');
XHR.appendData('t','$t');
XHR.sendAndLoad('$page', 'POST',x_GetLogs$t);
}
</script>
";
echo $tpl->_ENGINE_parse_body($html);
}
function restorefrom(){
$sock=new sockets();
$path=base64_encode($_POST["restore-path"]);
$sock->getFrameWork("zarafa.php?zarafadb-restore=$path");
}
function logs_starter(){
$t=$_GET["t"];
$html=" <textarea style='margin-top:5px;font-family:Courier New;
font-weight:bold;width:100%;height:446px;border:5px solid #8E8E8E;
overflow:auto;font-size:11px' id='textToParseCats-$t'></textarea>
<script>
setTimeout(\"GetLogs$t()\",1000);
</script>";
echo $html;
}
function restorelogs(){
$logfile="/usr/share/artica-postfix/ressources/logs/web/zarafa_restore_task.log";
$f=explode("\n",@file_get_contents($logfile));
krsort($f);
echo $f;
}