forked from webmin/webmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit.cgi
executable file
·93 lines (79 loc) · 2.67 KB
/
edit.cgi
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
#!/usr/local/bin/perl
# Edit or create a scheduled cluster copy
require './cluster-copy-lib.pl';
&ReadParse();
&foreign_require("servers", "servers-lib.pl");
if (!$in{'new'}) {
$copy = &get_copy($in{'id'});
$job = &find_cron_job($copy);
&ui_print_header(undef, $text{'edit_title'}, "");
}
else {
&ui_print_header(undef, $text{'create_title'}, "");
$copy = { 'mins' => '0',
'hours' => '0',
'days' => '*',
'months' => '*',
'weekdays' => '*',
'sched' => 1,
'dest' => '/' };
}
print &ui_form_start("save.cgi", "post");
print &ui_hidden("new", $in{'new'});
print &ui_hidden("id", $in{'id'});
print &ui_table_start($text{'edit_header'}, "width=100%", 2);
# Files to copy
print &ui_table_row($text{'edit_files'},
&ui_textarea("files",
join("\n", split(/\t+/, $copy->{'files'})), 5, 60)." ".
&file_chooser_button("files", 0, undef, undef, 1));
# Destination directory
print &ui_table_row($text{'edit_dest'},
&ui_textbox("dest", $copy->{'dest'}, 50));
print &ui_table_row(" ",
&ui_radio("dmode", $copy->{'dmode'} || 0,
[ [ 0, $text{'edit_dmode0'} ],
[ 1, $text{'edit_dmode1'} ] ]));
# Command to run before copy
print &ui_table_row($text{'edit_before'},
&ui_textbox("before", $copy->{'before'}, 60)." ".
&ui_checkbox("beforeremote", 1, $text{'edit_remote'},
!$copy->{'beforelocal'}));
# Command to run after copy
print &ui_table_row($text{'edit_cmd'},
&ui_textbox("cmd", $copy->{'cmd'}, 60)." ".
&ui_checkbox("cmdremote", 1, $text{'edit_remote'},
!$copy->{'cmdlocal'}));
# Target servers
@sel = split(/\s+/, $copy->{'servers'});
push(@opts, [ "ALL", $text{'edit_all'} ]);
push(@opts, [ "*", $text{'edit_this'} ]);
foreach $s (grep { $_->{'user'} } &servers::list_servers()) {
push(@opts, [ $s->{'host'}, $s->{'desc'} || $s->{'host'} ]);
}
foreach $g (&servers::list_all_groups()) {
push(@opts, [ "group_".$g->{'name'},
&text('edit_group', $g->{'name'}) ]);
}
print &ui_table_row($text{'edit_servers'},
&ui_select("servers", \@sel, \@opts, 8, 1));
# Cron enabled
print &ui_table_row($text{'edit_sched'},
&ui_radio("sched", $job || $in{'new'} ? 1 : 0,
[ [ 0, $text{'no'} ],
[ 1, $text{'edit_schedyes'} ] ]));
# Send email to
print &ui_table_row($text{'edit_email'},
&ui_opt_textbox("email", $copy->{'email'}, 50, $text{'edit_none'}));
# Cron times
print &cron::get_times_input($copy);
print &ui_table_end();
if ($in{'new'}) {
print &ui_form_end([ [ 'create', $text{'create'} ] ], "100%");
}
else {
print &ui_form_end([ [ 'save', $text{'save'} ],
[ 'run', $text{'edit_run'} ],
[ 'delete', $text{'delete'} ] ], "100%");
}
&ui_print_footer("", $text{'index_return'});