Handle hostnames with upper-case letters
[webmin.git] / backup-config / edit.cgi
1 #!/usr/local/bin/perl
2 # Show one scheduled backup
3
4 use strict;
5 use warnings;
6 require './backup-config-lib.pl';
7 our (%in, %text);
8 &ReadParse();
9
10 my $backup;
11 if ($in{'new'}) {
12         &ui_print_header(undef, $text{'edit_title1'}, "");
13         $backup = { 'emode' => 0,
14                     'sched' => 1,
15                     'mins' => 0,
16                     'hours' => 0,
17                     'days' => '*',
18                     'months' => '*',
19                     'weekdays' => '*' };
20         }
21 else {
22         &ui_print_header(undef, $text{'edit_title2'}, "");
23         $backup = &get_backup($in{'id'});
24         }
25
26 print &ui_form_start("save.cgi", "post");
27 print &ui_hidden("new", $in{'new'});
28 print &ui_hidden("id", $in{'id'});
29
30 my @tds = ( "width=30%" );
31 print &ui_hidden_table_start($text{'edit_header'}, "width=100%", 2,
32                              "main", 1, \@tds);
33
34 # Show modules to backup
35 my @mods = &list_backup_modules();
36 my @dmods = split(/\s+/, $backup->{'mods'});
37 print &ui_table_row($text{'edit_mods'},
38                     &ui_select("mods", \@dmods,
39                        [ map { [ $_->{'dir'}, $_->{'desc'} ] } @mods ],
40                        10, 1));
41
42 # Show destination
43 print &ui_table_row($text{'edit_dest'},
44                     &show_backup_destination("dest", $backup->{'dest'}, 0));
45
46 # Show files to include
47 print &ui_table_row($text{'edit_what'},
48                     &show_backup_what("what", $backup->{'configfile'},
49                                               $backup->{'nofiles'},
50                                               $backup->{'others'}));
51
52 print &ui_hidden_table_end();
53
54 print &ui_hidden_table_start($text{'edit_header2'}, "width=100%", 2,
55                              "prepost", 0, \@tds);
56
57 # Show pre-backup command
58 print &ui_table_row($text{'edit_pre'},
59                     &ui_textbox("pre", $backup->{'pre'}, 60));
60
61 # Show post-backup command
62 print &ui_table_row($text{'edit_post'},
63                     &ui_textbox("post", $backup->{'post'}, 60));
64
65 print &ui_hidden_table_end();
66
67 print &ui_hidden_table_start($text{'edit_header3'}, "width=100%", 2,
68                              "sched", 0, \@tds);
69
70 # Show email address
71 print &ui_table_row($text{'edit_email'},
72                     &ui_textbox("email", $backup->{'email'}, 40));
73
74 # Show email mode
75 print &ui_table_row($text{'edit_emode'},
76                     &ui_radio("emode", $backup->{'emode'},
77                               [ [ 0, $text{'edit_emode0'} ],
78                                 [ 1, $text{'edit_emode1'} ] ]));
79
80 # Show schedule
81 my $job;
82 if ($backup) {
83         $job = &find_cron_job($backup);
84         }
85 print &ui_table_row($text{'edit_sched'},
86                     &ui_radio("sched", $job || $in{'new'} ? 1 : 0,
87                               [ [ 0, $text{'no'} ],
88                                 [ 1, $text{'edit_schedyes'} ] ]));
89 print &ui_table_row(undef,
90         "<tr> <td colspan=2><table border width=100%>\n".
91         &capture_function_output(\&cron::show_times_input, $backup).
92         "</table></td> </tr>\n");
93
94 print &ui_hidden_table_end();
95 if ($in{'new'}) {
96         print &ui_form_end([ [ 'create', $text{'create'} ] ], "100%");
97         }
98 else {
99         print &ui_form_end([ [ 'save', $text{'save'} ],
100                              [ 'run', $text{'edit_run'} ],
101                              [ 'delete', $text{'delete'} ] ], "100%");
102         }
103
104 &ui_print_footer("", $text{'index_return'});
105
106