Handle hostnames with upper-case letters
[webmin.git] / itsecur-firewall / edit_time.cgi
1 #!/usr/bin/perl
2 # edit_time.cgi
3 # Show a form for editing or creating a time range
4
5 require './itsecur-lib.pl';
6 &can_use_error("times");
7 &ReadParse();
8 if ($in{'new'}) {
9         &header($text{'time_title1'}, "",
10                 undef, undef, undef, undef, &apply_button());
11         $time = { 'hours' => '*',
12                   'days' => '*' };
13         }
14 else {
15         &header($text{'time_title2'}, "",
16                 undef, undef, undef, undef, &apply_button());
17         @times = &list_times();
18         if (defined($in{'idx'})) {
19                 $time = $times[$in{'idx'}];
20                 }
21         else {
22                 ($time) = grep { $_->{'name'} eq $in{'name'} } @times;
23                 $in{'idx'} = $time->{'index'};
24                 }
25         }
26 print "<hr>\n";
27
28 print "<form action=save_time.cgi>\n";
29 print "<input type=hidden name=new value='$in{'new'}'>\n";
30 print "<input type=hidden name=idx value='$in{'idx'}'>\n";
31 print "<table border>\n";
32 print "<tr $tb> <td><b>$text{'time_header'}</b></td> </tr>\n";
33 print "<tr $cb> <td><table>\n";
34
35 # Show range name
36 print "<tr> <td><b>$text{'time_name'}</b></td>\n";
37 printf "<td><input name=name size=20 value='%s'></td> </tr>\n",
38         $time->{'name'};
39
40 # Show hour range
41 print "<tr> <td><b>$text{'time_hours'}</b></td> <td>\n";
42 printf "<input type=radio name=hours_def value=1 %s> %s\n",
43         $time->{'hours'} eq "*" ? "checked" : "", $text{'time_allday'};
44 printf "<input type=radio name=hours_def value=0 %s>\n",
45         $time->{'hours'} eq "*" ? "" : "checked";
46 ($from, $to) = $time->{'hours'} eq "*" ? ( ) : split(/\-/, $time->{'hours'});
47 printf "%s <input name=from size=6 value='%s'>\n",
48         $text{'time_from'}, $from;
49 printf "%s <input name=to size=6 value='%s'></td> </tr>\n",
50         $text{'time_to'}, $to;
51
52 # Show days of week
53 print "<tr> <td valign=top><b>$text{'time_days'}</b></td> <td>\n";
54 printf "<input type=radio name=days_def value=1 %s> %s\n",
55         $time->{'days'} eq "*" ? "checked" : "", $text{'time_allweek'};
56 printf "<input type=radio name=days_def value=0 %s> %s<br>\n",
57         $time->{'days'} eq "*" ? "" : "checked", $text{'time_sel'};
58 %days = map { $_, 1 } split(/,/, $time->{'days'});
59 print "<select name=days size=7 multiple>\n";
60 for($i=0; $i<7; $i++) {
61         printf "<option value=%s %s>%s\n",
62                 $i, $days{$i} ? "selected" : "", $text{'day_'.$i};
63         }
64 print "</select></td> </tr>\n";
65
66 print "</table></td></tr></table>\n";
67 if ($in{'new'}) {
68         print "<input type=submit value='$text{'create'}'>\n";
69         }
70 else {
71         print "<input type=submit value='$text{'save'}'>\n";
72         print "<input type=submit name=delete value='$text{'delete'}'>\n";
73         }
74 print "</form>\n";
75 &can_edit_disable("times");
76
77 print "<hr>\n";
78 &footer("list_times.cgi", $text{'times_return'});
79