Handle hostnames with upper-case letters
[webmin.git] / backup-config / index.cgi
1 #!/usr/local/bin/perl
2 # Show all scheduled backups, and a form for doing an immediate one
3
4 use strict;
5 use warnings;
6 require './backup-config-lib.pl';
7 our (%text, %in, %config);
8 &ReadParse();
9
10 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1);
11 my @mods = &list_backup_modules();
12 if (!@mods) {
13         &ui_print_endpage($text{'index_emods'});
14         }
15 my %mods = map { $_->{'dir'}, $_ } @mods;
16
17 # Show tabs
18 my @tabs = ( [ "backup", $text{'index_tabbackup'}, "index.cgi?mode=backup" ],
19              [ "sched", $text{'index_tabsched'}, "index.cgi?mode=sched" ],
20              [ "restore", $text{'index_tabrestore'}, "index.cgi?mode=restore" ],
21            );
22 print &ui_tabs_start(\@tabs, "tab", $in{'mode'} || "backup", 1);
23
24 print &ui_tabs_start_tab("tab", "sched");
25 my @backups = &list_backups();
26 my $using_strftime = 0;
27 if (@backups) {
28         # Show all scheduled backups
29         print "<a href='edit.cgi?new=1'>$text{'index_add'}</a><br>\n";
30         print &ui_columns_start([ $text{'index_dest'},
31                                   $text{'index_mods'},
32                                   $text{'index_sched'} ], 100);
33         foreach my $b (@backups) {
34                 my @m = map { $mods{$_}->{'desc'} }
35                             split(/\s+/, $b->{'mods'});
36                 print &ui_columns_row(
37                         [ "<a href='edit.cgi?id=$b->{'id'}'>".
38                           &nice_dest($b->{'dest'})."</a>",
39                           @m > 5 ? &text('index_count', scalar(@m))
40                                  : join(", ", @m),
41                           $b->{'sched'} ? &text('index_when',
42                                 &cron::when_text($b)) : $text{'no'} ]);
43                 $using_strftime++ if ($b->{'dest'} =~ /%/);
44                 }
45         print &ui_columns_end();
46         }
47 else {
48         print "<b>$text{'index_none'}</b><p>\n";
49         }
50 print "<a href='edit.cgi?new=1'>$text{'index_add'}</a><p>\n";
51 if ($using_strftime && !$config{'date_subs'}) {
52         print "<font color=#ff0000><b>$text{'index_nostrftime'}",
53               "</b></font><p>\n";
54         }
55 print &ui_tabs_end_tab();
56
57 # Show immediate form
58 print &ui_tabs_start_tab("tab", "backup");
59 print &ui_form_start("backup.cgi/backup.tgz", "post");
60 print &ui_table_start($text{'index_header'}, undef, 2);
61
62 my @dmods = split(/\s+/, $config{'mods'} || "");
63 print &ui_table_row($text{'edit_mods'},
64                     &ui_select("mods", \@dmods,
65                        [ map { [ $_->{'dir'}, $_->{'desc'} ] } @mods ],
66                        10, 1));
67
68 print &ui_table_row($text{'edit_dest'},
69                     &show_backup_destination("dest", $config{'dest'}, 2));
70
71 print &ui_table_row($text{'edit_what'},
72                     &show_backup_what("what", $config{'configfile'},
73                                               $config{'nofiles'}));
74
75 print &ui_table_end();
76 print &ui_form_end([ [ 'backup', $text{'index_now'} ] ]);
77
78 print &ui_tabs_end_tab();
79
80 # Show restore form
81 print &ui_tabs_start_tab("tab", "restore");
82 print &ui_form_start("restore.cgi", "form-data");
83 print &ui_table_start($text{'index_header2'}, undef, 2);
84
85 print &ui_table_row($text{'edit_mods2'},
86                     &ui_select("mods", \@dmods,
87                        [ map { [ $_->{'dir'}, $_->{'desc'} ] } @mods ],
88                        5, 1));
89
90 print &ui_table_row($text{'edit_dest2'},
91                     &show_backup_destination("src", $config{'dest'}, 1));
92
93 print &ui_table_row($text{'index_apply'},
94                     &ui_yesno_radio("apply", $config{'apply'} ? 1 : 0));
95
96 print &ui_table_row($text{'index_test'},
97                     &ui_yesno_radio("test", 0));
98
99 print &ui_table_end();
100 print &ui_form_end([ [ 'restore', $text{'index_now2'} ] ]);
101
102 print &ui_tabs_end_tab();
103 print &ui_tabs_end(1);
104
105 &ui_print_footer("/", $text{'index'});
106