-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbackup.tasks.php
808 lines (626 loc) · 23.4 KB
/
backup.tasks.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
<?php
include_once('ressources/class.templates.inc');
include_once('ressources/class.ldap.inc');
include_once('ressources/class.users.menus.inc');
include_once('ressources/class.groups.inc');
include_once('ressources/class.artica.inc');
include_once('ressources/class.main_cf.inc');
include_once('ressources/class.system.network.inc');
include_once('ressources/class.mysql.inc');
include_once('ressources/class.cron.inc');
include_once('ressources/class.backup.inc');
$user=new usersMenus();
if($user->AsSystemAdministrator==false){
$tpl=new templates();
echo "alert('". $tpl->javascript_parse_text("{ERROR_NO_PRIVS}")."');";
die();exit();
}
if(isset($_GET["popup"])){popup();exit;}
if(isset($_GET["show_backuped_folders"])){FOLDERS_BACKUPED();exit;}
if(isset($_GET["ExecBackupTemporaryPath"])){BACKUP_OPTIONS_SAVE();exit;}
if(isset($_GET["BACKUP_TASKS_LISTS"])){tasks_list();exit;}
if(isset($_GET["show_tasks"])){show_tasks();exit;}
if(isset($_GET["BACKUP_TASK_RUN"])){BACKUP_TASK_RUN();exit;}
if(isset($_GET["backup-sources"])){BACKUP_SOURCES();exit;}
if(isset($_GET["DeleteBackupSource"])){BACKUP_SOURCES_DELETE();exit;}
if(isset($_GET["DeleteBackupTask"])){BACKUP_TASK_DELETE();exit;}
if(isset($_GET["adv-options"])){BACKUP_OPTIONS();exit;}
if(isset($_GET["backup-tests"])){BACKUP_TASK_TEST();exit;}
if(isset($_GET["backup_stop_imap"])){BACKUP_SOURCES_SAVE_OPTIONS();exit;}
if(isset($_GET["FOLDER_BACKUP"])){FOLDER_BACKUP_JS();exit;}
if(isset($_GET["FOLDER_BACKUP_POPUP"])){FOLDER_BACKUP_POPUP();exit;}
if(isset($_GET["BACKUP_FOLDER_ENABLE"])){BACKUP_FOLDER_ENABLE();exit;}
if(isset($_GET["FOLDER_BACKUP_DELETE"])){FOLDERS_BACKUPED_DELETE();exit;}
if(isset($_GET["TASK_EVENTS_DETAILS"])){TASK_EVENTS_DETAILS();exit;}
if(isset($_GET["TASK_EVENTS_DETAILS_INFOS"])){TASK_EVENTS_DETAILS_INFOS();exit;}
if(isset($_GET["events"])){BACKUP_EVENTS();exit;}
js();
function FOLDER_BACKUP_JS(){
$page=CurrentPageName();
$tpl=new templates();
$title=$tpl->_ENGINE_parse_body("{backup_a_folder}");
$folder=$_GET["FOLDER_BACKUP"];
$html="
function FOLDER_BACKUP_START(){
YahooWin(600,'$page?FOLDER_BACKUP_POPUP=yes&folder=$folder','$title');
}
var x_BACKUP_FOLDER_ENABLE= function (obj) {
var tempvalue=obj.responseText;
if(tempvalue.length>0){alert(tempvalue)};
}
function BACKUP_FOLDER_ENABLE(taskid){
var XHR = new XHRConnection();
XHR.appendData('BACKUP_FOLDER_ENABLE',taskid);
if(document.getElementById('task_folder_'+taskid).checked){
XHR.appendData('ENABLE',1);
}else{
XHR.appendData('ENABLE',0);
}
if(document.getElementById('recursive_folder_'+taskid).checked){
XHR.appendData('RECURSIVE',1);
}else{
XHR.appendData('RECURSIVE',0);
}
XHR.appendData('folder','$folder');
XHR.sendAndLoad('$page', 'GET',x_BACKUP_FOLDER_ENABLE);
}
FOLDER_BACKUP_START();
";
echo $html;
}
function BACKUP_FOLDER_ENABLE(){
$taskid=$_GET["BACKUP_FOLDER_ENABLE"];
$folder=$_GET["folder"];
$RECURSIVE=$_GET["RECURSIVE"];
$sql="SELECT ID FROM backup_folders WHERE path='$folder' AND taskid='$taskid'";
$q=new mysql();
$ligne=@mysql_fetch_array($q->QUERY_SQL($sql,"artica_backup"));
$ID=$ligne["ID"];
if($ID==0){
if($_GET["ENABLE"]==0){return;}
if($_GET["ENABLE"]==1){
$sql="INSERT INTO backup_folders (path,taskid,recursive) VALUES('$folder',$taskid,$RECURSIVE)";
$q->QUERY_SQL($sql,"artica_backup");
if(!$q->ok){echo $q->mysql_error;}
return;
}
}
if($_GET["ENABLE"]==0){
$sql="DELETE FROM backup_folders WHERE ID=$ID";
$q->QUERY_SQL($sql,"artica_backup");
if(!$q->ok){echo $q->mysql_error;}
return;
}
$sql="UPDATE backup_folders SET recursive=$RECURSIVE WHERE ID=$ID";
$q->QUERY_SQL($sql,"artica_backup");
if(!$q->ok){echo $q->mysql_error;}
}
function FOLDERS_BACKUPED(){
$page=CurrentPageName();
$tpl=new templates();
$q=new mysql();
$cron=new cron_macros();
$sql="SELECT * FROM backup_schedules ORDER BY ID DESC";
$results=$q->QUERY_SQL($sql,"artica_backup");
$backup=new backup_protocols();
while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){
$TASK_EX[$ligne["ID"]]=$backup->backuptypes[$ligne["resource_type"]]." (".$cron->cron_human($ligne["schedule"]).")";
}
$html=$html."
<div id='FOLDER_BACKUPED_DIV'>
<table style='width:99%'>
<th>{task}</th>
<th> </th>
<th>{path}</th>
<th>{recursive}</th>
<th> </th>
</tr>";
$sql="SELECT * FROM backup_folders ORDER BY ID DESC";
$results=$q->QUERY_SQL($sql,"artica_backup");
while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){
if($ligne["recursive"]==1){$ligne["recursive"]="{enabled}";}else{$ligne["recursive"]="{disabled}";}
$html=$html.
"<tr ". CellRollOver().">
<td width=1% align='center'><strong style='font-size:12px'>{$ligne["taskid"]}</strong></td>
<td style='font-size:12px' nowrap>". $TASK_EX[$ligne["taskid"]]."</td>
<td style='font-size:12px' width=98%><code>". base64_decode($ligne["path"])."</code></td>
<td width=1% style='font-size:12px' align='left'>{$ligne["recursive"]}</td>
<td width=1% style='font-size:12px' align='left'>". imgtootltip("ed_delete.gif","{delete}","FOLDER_BACKUP_DELETE({$ligne["ID"]})")."</td>
</tr>";
}
$html=$html."</table></div>
<script>
var x_FOLDER_BACKUP_DELETE= function (obj) {
var tempvalue=obj.responseText;
if(tempvalue.length>0){alert(tempvalue)};
}
function FOLDER_BACKUP_DELETE(ID){
var XHR = new XHRConnection();
XHR.appendData('FOLDER_BACKUP_DELETE',ID);
document.getElementById('FOLDER_BACKUPED_DIV').innerHTML='<center><img src=img/wait_verybig.gif></center>';
XHR.sendAndLoad('$page', 'GET',x_FOLDER_BACKUP_DELETE);
RefreshTab('main_config_backup_tasks');
}
</script>
";
echo $tpl->_ENGINE_parse_body($html);
}
function FOLDERS_BACKUPED_DELETE(){
$ID=$_GET["FOLDER_BACKUP_DELETE"];
$q=new mysql();
$sql="DELETE FROM backup_folders WHERE ID='$ID'";
$q->QUERY_SQL($sql,"artica_backup");
writelogs("$sql",__FUNCTION__,__FILE__,__LINE__);
if(!$q->ok){echo $q->mysql_error;}
}
function FOLDER_BACKUP_POPUP(){
$page=CurrentPageName();
$tpl=new templates();
$backup_decoded=base64_decode($_GET["folder"]);
$cron=new cron_macros();
$html="<H3>{backup_this_directory}: $backup_decoded</H3>
<p style='font-size:13px'>{backup_this_directory_explain}</p>
";
$sql="SELECT taskid,recursive FROM backup_folders WHERE path='{$_GET["folder"]}'";
$q=new mysql();
$results=$q->QUERY_SQL($sql,"artica_backup");
while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){
$tasks[$ligne["taskid"]]=1;
$recursive[$ligne["taskid"]]=$ligne["recursive"];
}
$sql="SELECT * FROM backup_schedules ORDER BY ID DESC";
$q=new mysql();
$results=$q->QUERY_SQL($sql,"artica_backup");
$backup=new backup_protocols();
$html=$html."<table style='width:99%'>
<th>{task}</th>
<th>{STORAGE_TYPE}</th>
<th>{schedule}</th>
<th>{enabled}</th>
<th>{recursive}</th>
</tr>";
while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){
$enable=Field_checkbox("task_folder_{$ligne["ID"]}",1,$tasks[$ligne["ID"]],"BACKUP_FOLDER_ENABLE({$ligne["ID"]})");
$recursive=Field_checkbox("recursive_folder_{$ligne["ID"]}",1,$recursive[$ligne["ID"]],"BACKUP_FOLDER_ENABLE({$ligne["ID"]})");
$html=$html.
"<tr ". CellRollOver().">
<td width=1% align='center'><strong style='font-size:12px'>{$ligne["ID"]}</strong></td>
<td style='font-size:12px'>{$backup->backuptypes[$ligne["resource_type"]]}</td>
<td style='font-size:12px'>". $cron->cron_human($ligne["schedule"])."</td>
<td style='font-size:12px' align='center'>$enable</td>
<td style='font-size:12px' align='center'>$recursive</td>
</tr>";
}
$html=$html."</table>";
echo $tpl->_ENGINE_parse_body($html);
}
function js(){
$page=CurrentPageName();
$tpl=new templates();
$title=$tpl->_ENGINE_parse_body("{BACKUP_TASKS}");
$sources=$tpl->_ENGINE_parse_body("{sources}");
$BACKUP_TASK_CONFIRM_DELETE=$tpl->javascript_parse_text("{BACKUP_TASK_CONFIRM_DELETE}");
$BACKUP_TASK_CONFIRM_DELETE_SOURCE=$tpl->javascript_parse_text("{BACKUP_TASK_CONFIRM_DELETE_SOURCE}");
$tests=$tpl->javascript_parse_text("{test}");
$backupTaskRunAsk=$tpl->javascript_parse_text("{backupTaskRunAsk}");
$apply_upgrade_help=$tpl->javascript_parse_text("{apply_upgrade_help}");
$events=$tpl->_ENGINE_parse_body("{events}");
$html="
mem_taskid='';
function BACKUP_TASKS_LOAD(){
YahooWin2('785','$page?popup=yes','$title');
}
function BACKUP_TASKS_LISTS(){
LoadAjax('taskslists','$page?BACKUP_TASKS_LISTS=yes');
}
function BACKUP_TASKS_SOURCE(ID){
YahooWin3('500','$page?backup-sources=yes&ID='+ID,'$sources');
}
function TASK_EVENTS_DETAILS(ID){
YahooWin3('700','$page?TASK_EVENTS_DETAILS='+ID,ID+'::$events');
}
function TASK_EVENTS_DETAILS_INFOS(ID){
YahooWin4('700','$page?TASK_EVENTS_DETAILS_INFOS='+ID,ID+'::$events');
}
var x_DeleteBackupTask= function (obj) {
var tempvalue=obj.responseText;
if(tempvalue.length>0){alert(tempvalue)};
BACKUP_TASKS_LOAD();
if(document.getElementById('wizard-backup-intro')){
WizardBackupLoad();
}
}
var x_DELETE_BACKUP_SOURCES= function (obj) {
var tempvalue=obj.responseText;
if(tempvalue.length>0){alert(tempvalue)};
BACKUP_TASKS_LOAD();
YahooWin3Hide();
}
function DeleteBackupTask(ID){
if(confirm('$BACKUP_TASK_CONFIRM_DELETE')){
var XHR = new XHRConnection();
XHR.appendData('DeleteBackupTask',ID);
XHR.sendAndLoad('$page', 'GET',x_DeleteBackupTask);
}
}
function DELETE_BACKUP_SOURCES(ID,INDEX){
if(confirm('$BACKUP_TASK_CONFIRM_DELETE_SOURCE')){
var XHR = new XHRConnection();
XHR.appendData('DeleteBackupSource','yes');
XHR.appendData('ID',ID);
XHR.appendData('INDEX',INDEX);
XHR.sendAndLoad('$page', 'GET',x_DELETE_BACKUP_SOURCES);
}
}
var x_BACKUP_SOURCES_SAVE_OPTIONS= function (obj) {
var tempvalue=obj.responseText;
if(tempvalue.length>0){alert(tempvalue)};
BACKUP_TASKS_SOURCE(mem_taskid);
}
function BACKUP_SOURCES_SAVE_OPTIONS(taskid){
mem_taskid=taskid;
var XHR = new XHRConnection();
if(document.getElementById('backup_stop_imap').checked){
XHR.appendData('backup_stop_imap',1);}else{
XHR.appendData('backup_stop_imap',0);}
XHR.appendData('taskid',taskid);
document.getElementById('BACKUP_SOURCES_OPTIONS').innerHTML='<center><img src=img/wait_verybig.gif></center>';
XHR.sendAndLoad('$page', 'GET',x_BACKUP_SOURCES_SAVE_OPTIONS);
}
function BACKUP_TASK_TEST(ID){
YahooWin3('500','$page?backup-tests=yes&ID='+ID,'$tests');
}
var x_BACKUP_TASK_RUN= function (obj) {
var tempvalue=obj.responseText;
if(tempvalue.length>0){alert(tempvalue)};
alert('$apply_upgrade_help');
BACKUP_TASKS_LOAD();
}
function BACKUP_TASK_RUN(ID){
if(confirm('$backupTaskRunAsk')){
var XHR = new XHRConnection();
XHR.appendData('BACKUP_TASK_RUN',ID);
XHR.sendAndLoad('$page', 'GET',x_BACKUP_TASK_RUN);
}
}
BACKUP_TASKS_LOAD();";
echo $html;
}
function popup(){
$tpl=new templates();
$array["show_tasks"]='{tasks}';
$array["show_backuped_folders"]='{backuped_folders}';
$array["adv-options"]='{advanced_options}';
$array["events"]='{events}';
$page=CurrentPageName();
while (list ($num, $ligne) = each ($array) ){
$html[]= $tpl->_ENGINE_parse_body("<li><a href=\"$page?$num=yes\"><span>$ligne</span></li>\n");
}
echo "
<div id=main_config_backup_tasks style='width:100%;height:350px;overflow:auto'>
<ul>". implode("\n",$html)."</ul>
</div>
<script>
$(document).ready(function(){
$('#main_config_backup_tasks').tabs({
load: function(event, ui) {
$('a', ui.panel).click(function() {
$(ui.panel).load(this.href);
return false;
});
}
});
});
</script>";
}
function show_tasks(){
$html="
<div id='taskslists'></div>
<script>
BACKUP_TASKS_LISTS();
</script>
";
$tpl=new templates();
echo $tpl->_ENGINE_parse_body($html);
}
function FOLDER_BACKUPED_NUMBER($taskid){
$q=new mysql();
$sql="SELECT COUNT(ID) AS tcount FROM backup_folders WHERE taskid=$taskid";
$ligne=@mysql_fetch_array($q->QUERY_SQL($sql,"artica_backup"));
if($ligne["tcount"]==null){$ligne["tcount"]=0;}
return $ligne["tcount"];
}
function tasks_list(){
$sql=new mysql();
$sock=new sockets();
$sql="SELECT * FROM backup_schedules ORDER BY ID DESC";
$q=new mysql();
$results=$q->QUERY_SQL($sql,"artica_backup");
$backup=new backup_protocols();
$cron=new cron_macros();
$storages["usb"]="{usb_external_drive}";
$storages["smb"]="{remote_smb_server}";
$storages["rsync"]="{remote_rsync_server}";
$html="<table style='width:99%'>
<th>{task}</th>
<th> </th>
<th> </th>
<th>{test}</th>
<th>{STORAGE_TYPE}</th>
<th>{resource}</th>
<th>{schedule}</th>
<th>{sources}</th>
<th> </th>
</tr>";
while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){
$ressources=unserialize(base64_decode($ligne["datasbackup"]));
$sources=(count($ressources)-1)+FOLDER_BACKUPED_NUMBER($ligne["ID"])." {sources}";
$sources=texttooltip($sources,"{show}","BACKUP_TASKS_SOURCE({$ligne["ID"]})",null,0,"font-size:12px");
$run=imgtootltip("run-24.png","{run_task}","BACKUP_TASK_RUN({$ligne["ID"]})");
if($ligne["pid"]>5){
$array_pid=unserialize(base64_decode($sock->getFrameWork("cmd.php?procstat={$ligne["pid"]}")));
if($array_pid["since"]<>null){
$run=imgtootltip("ajax-menus-loader.gif","{running}: {since} {$array_pid["since"]}","");
}
}
$html=$html.
"<tr ". CellRollOver().">
<td width=1% align='center'><strong style='font-size:12px'>{$ligne["ID"]}</strong></td>
<td width=1% style='font-size:12px' align='left'>". imgtootltip("events-24.png","{events}","TASK_EVENTS_DETAILS({$ligne["ID"]})")."</td>
<td width=1%>$run</td>
<td width=1%>". imgtootltip("eclaire-24.png","{BACKUP_TASK_TEST}","BACKUP_TASK_TEST({$ligne["ID"]})")."</td>
<td style='font-size:12px' nowrap>{$storages[$ligne["resource_type"]]}</td>
<td style='font-size:12px'>". $backup->extractFirsRessource($ligne["pattern"])."</td>
<td style='font-size:12px' nowrap>". $cron->cron_human($ligne["schedule"])."</td>
<td style='font-size:12px'>$sources</td>
<td style='font-size:12px'>". imgtootltip("delete-24.png","{delete}","DeleteBackupTask({$ligne["ID"]})")."</td>
</tr>";
}
$html=$html."</table>
<hr>
<table style='width:100%'>
<tr>
<td align='left'>". button("{add_task}","Loadjs('wizard.backup-all.php');")."</td>
<td align='right'><div style='width:100%;text-align:right'>". imgtootltip('32-refresh.png',"{refresh}","BACKUP_TASKS_LISTS()")."</div></td>
</tr>
</table>
";
$tpl=new templates();
echo $tpl->_ENGINE_parse_body($html);
}
function BACKUP_SOURCES(){
$sql="SELECT datasbackup FROM backup_schedules WHERE ID='{$_GET["ID"]}'";
$q=new mysql();
$ligne=@mysql_fetch_array($q->QUERY_SQL($sql,"artica_backup"));
$ressources=unserialize(base64_decode($ligne["datasbackup"]));
$html="
<div style='width:100%;height:150px;overflow:auto;'>
<table style='width:99%'>";
if(is_array($ressources)){
while (list ($num, $val) = each ($ressources) ){
if(is_array($val)){continue;}
$val=str_replace("all","{BACKUP_ALL_MEANS}",$val);
$html=$html.
"
<tr><td colspan=4 style='border-top:1px solid #005447'> </td></tr>
<tr ". CellRollOver().">
<td widh=1% valign='top'><img src='img/fw_bold.gif'></td>
<td widh=1% valign='top' style='font-size:12px'><STRONG>{source} $num</STRONG></td>
<td width=99%><code style='font-size:12px;font-weight:bold'>$val</td>
<td widh=1% valign='top'>". imgtootltip("ed_delete.gif","{delete}","DELETE_BACKUP_SOURCES({$_GET["ID"]},$num)")."</td>
</tr>
";
}
}
$sql="SELECT * FROM backup_folders WHERE taskid={$_GET["ID"]}";
$results=$q->QUERY_SQL($sql,"artica_backup");
while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){
if($ligne["recursive"]==1){$ligne["recursive"]="{enabled}";}else{$ligne["recursive"]="{disabled}";}
$html=$html.
"<tr><td colspan=4 style='border-top:1px solid #005447'> </td></tr>
<tr ". CellRollOver().">
<td widh=1% valign='top'><img src='img/fw_bold.gif'></td>
<td style='font-size:12px' nowrap><strong>{folder}</strong></td>
<td style='font-size:12px;font-weight:bold' width=98%><code>". base64_decode($ligne["path"])."</code></td>
<td width=1% style='font-size:12px' align='left'> </td>
</tr>";
}
$html=$html."
</table>
</div>
<BR>
<div id='BACKUP_SOURCES_OPTIONS'>
<H3>{options}</H3>
<table style='width:100%'>
<tr>
<td valign='top' class=legend>{backup_stop_imap}:</td>
<td valign='top'>". Field_checkbox("backup_stop_imap",1,$ressources["OPTIONS"]["STOP_IMAP"])."</td>
</tr>
<tr>
<td colspan=2 align='right'>
<hr>
". button("{apply}","BACKUP_SOURCES_SAVE_OPTIONS({$_GET["ID"]})")."
</td>
</tr>
</table>
</div>";
$tpl=new templates();
echo $tpl->_ENGINE_parse_body($html);
}
function BACKUP_TASK_RUN(){
$sock=new sockets();
$sock->getFrameWork("cmd.php?backup-task-run={$_GET["BACKUP_TASK_RUN"]}");
}
function BACKUP_SOURCES_DELETE(){
$sql="SELECT datasbackup FROM backup_schedules WHERE ID='{$_GET["ID"]}'";
$q=new mysql();
$ligne=@mysql_fetch_array($q->QUERY_SQL($sql,"artica_backup"));
$ressources=unserialize(base64_decode($ligne["datasbackup"]));
unset($ressources[$_GET["INDEX"]]);
$new_ressources=base64_encode(serialize($ressources));
$sql="UPDATE backup_schedules SET datasbackup='$new_ressources' WHERE ID='{$_GET["ID"]}'";
$q->QUERY_SQL($sql,"artica_backup");
$sock=new sockets();
$sock->getFrameWork("cmd.php?backup-build-cron=yes");
}
function BACKUP_SOURCES_SAVE_OPTIONS(){
$sql="SELECT datasbackup FROM backup_schedules WHERE ID='{$_GET["taskid"]}'";
$q=new mysql();
$ligne=@mysql_fetch_array($q->QUERY_SQL($sql,"artica_backup"));
$ressources=unserialize(base64_decode($ligne["datasbackup"]));
$ressources["OPTIONS"]["STOP_IMAP"]=$_GET["backup_stop_imap"];
$new_ressources=base64_encode(serialize($ressources));
$sql="UPDATE backup_schedules SET datasbackup='$new_ressources' WHERE ID='{$_GET["taskid"]}'";
$q->QUERY_SQL($sql,"artica_backup");
}
function BACKUP_TASK_DELETE(){
$sql="DELETE FROM backup_schedules WHERE ID='{$_GET["DeleteBackupTask"]}'";
$q=new mysql();
$q->QUERY_SQL($sql,"artica_backup");
$sql="DELETE FROM backup_events WHERE task_id='{$_GET["DeleteBackupTask"]}'";
$q->QUERY_SQL($sql,"artica_events");
$sock=new sockets();
$sock->getFrameWork("cmd.php?backup-build-cron=yes");
}
function BACKUP_TASK_TEST(){
$sock=new sockets();
$datas=unserialize(base64_decode($sock->getFrameWork("cmd.php?backup-sql-test={$_GET["ID"]}")));
while (list ($num, $val) = each ($datas) ){
if(preg_match("#^.+?](.+?)in\s+#",$val,$re)){
$html=$html."<div>{$re[1]}</div>";
}
}
$tpl=new templates();
echo $tpl->_ENGINE_parse_body($html);
}
function BACKUP_OPTIONS_SAVE(){
$sock=new sockets();
$sock->SET_INFO("ExecBackupTemporaryPath",$_GET["ExecBackupTemporaryPath"]);
}
function BACKUP_OPTIONS(){
$sock=new sockets();
$page=CurrentPageName();
$temporarySourceDir=$sock->GET_INFO("ExecBackupTemporaryPath");
if($temporarySourceDir==null){$temporarySourceDir="/home/mysqlhotcopy";}
$html="
<div id='backup-adv-options'>
<table style='width:100%'>
<tr>
<td class=legend style='font-size:13px'>{ExecBackupTemporaryPath}:</td>
<td>". Field_text("ExecBackupTemporaryPath",$temporarySourceDir,"font-size:13px;width:220px")."
</tr>
<tr>
<td colspan=2 align='right'>". button("{apply}","SAVE_BACKUP_OPTIONS()")."</td>
</tr>
</table>
</div>
<script>
var x_SAVE_BACKUP_OPTIONS= function (obj) {
var tempvalue=obj.responseText;
if(tempvalue.length>0){alert(tempvalue)};
RefreshTab('main_config_backup_tasks');
}
function SAVE_BACKUP_OPTIONS(){
var XHR = new XHRConnection();
XHR.appendData('ExecBackupTemporaryPath',document.getElementById('ExecBackupTemporaryPath').value);
document.getElementById('backup-adv-options').innerHTML='<center><img src=img/wait_verybig.gif></center>';
XHR.sendAndLoad('$page', 'GET',x_SAVE_BACKUP_OPTIONS);
}
</script>";
$tpl=new templates();
echo $tpl->_ENGINE_parse_body($html);
}
function BACKUP_EVENTS(){
$html="<table style='width:99%'>
<th> </th>
<th>{date}</th>
<th>{source}</th>
<th>{resource}</th>
<th>{status}</th>
</tr>";
$backup=new backup_protocols();
$sql="SELECT * FROM `cyrus_backup_events` ORDER BY `cyrus_backup_events`.`ID` DESC LIMIT 0 , 200";
$q=new mysql();
$results=$q->QUERY_SQL($sql,"artica_events");
while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){
$img="status_ok.gif";
if($ligne["success"]==0){$img="status_critical.gif";}
$array=$backup->ParseProto($ligne["remote_ressource"]);
$html=$html.
"
<tr ". CellRollOver().">
<td widh=1% valign='top'><img src='img/fw_bold.gif'></td>
<td style='font-size:12px' nowrap><strong>{$ligne["zDate"]}</strong></td>
<td style='font-size:12px;font-weight:bold' width=98%><code>{$ligne["local_ressource"]}</code></td>
<td style='font-size:12px' align='left' nowrap>{$array["SERVER"]}</td>
<td width=1% style='font-size:12px' align='left'><img src='img/$img'></td>
</tr>
<tr><td colspan=5 style='border-bottom:1px solid #005447' align=right><i style='font-size:11px'>{$ligne["events"]}</i></td></tr>";
}
$html=$html."
</table>";
$tpl=new templates();
echo $tpl->_ENGINE_parse_body($html);
}
function TASK_EVENTS_DETAILS_INFOS(){
$ID=$_GET["TASK_EVENTS_DETAILS_INFOS"];
$sql="SELECT * FROM backup_events WHERE ID=$ID";
$q=new mysql();
$ligne=mysql_fetch_array($q->QUERY_SQL($sql,"artica_events"));
$html="<H2>$ID) {$ligne["zdate"]}::{$ligne["backup_source"]}</H2>
<div style='height:300px;overflow:auto;border:1px solid #CCCCCC;padding:5px;margin:5px'>";
$events=@explode("\n",$ligne["event"]);
while (list ($num, $line) = each ($events)){
$html=$html. "<div style='padding:2px'><code>".htmlspecialchars($line)."</code></div>";
}
$html=$html."</div>";
echo $html;
}
function TASK_EVENTS_DETAILS(){
$ID=$_GET["TASK_EVENTS_DETAILS"];
$html="<div style='height:300px;overflow:auto'>
<table style='width:99%'>
<th> </th>
<th>{date}</th>
<th>{resource}</th>
<th>{status}</th>
<th>{events}</th>
</tr>";
$sql="SELECT *,DATE_FORMAT(zdate,'%W') as explainday,DATE_FORMAT(zdate,'%p') as tmorn,DATE_FORMAT(zdate,'%Hh%i') as ttime FROM `backup_events` WHERE `task_id`='$ID' ORDER BY `backup_events`.`zdate` DESC LIMIT 0 , 200";
$q=new mysql();
$results=$q->QUERY_SQL($sql,"artica_events");
while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){
if(strlen($ligne["event"])>60){$ligne["event"]=substr($ligne["event"],0,57)."...";}
if(preg_match("#^([A-Z]+).*?,#",$ligne["event"],$re)){
$status=$re[1];
$ligne["event"]=str_replace($re[1].',','',$ligne["event"]);
}
$ligne["explainday"]=strtolower($ligne["explainday"]);
$date="{{$ligne["explainday"]}} {$ligne["ttime"]}";
$img="info-18.png";
switch ($status) {
case "INFO":$img="info-18.png";break;
case "ERROR":$img="status_warning.gif";break;
default:
;
break;
}
$display="TASK_EVENTS_DETAILS_INFOS({$ligne["ID"]})";
$html=$html.
"
<tr ". CellRollOver($display,"{display}").">
<td width=1% valign='top'><img src='img/fw_bold.gif'></td>
<td width=1% style='font-size:12px' nowrap><strong>$date</strong></td>
<td style='font-size:12px' nowrap width=1%><strong>{$ligne["backup_source"]}</strong></td>
<td width=1% align='center' valign='middle'><img src='img/$img'></td>
<td style='font-size:12px' width=99% nowrap><strong>{$ligne["event"]}</strong></td>
</tr>
";
}
$html=$html."
</table>
</div>";
$tpl=new templates();
echo $tpl->_ENGINE_parse_body($html);
}
?>