Handle hostnames with upper-case letters
[webmin.git] / postfix / client.cgi
1 #!/usr/local/bin/perl
2 # A single page just for editing smtpd_client_restrictions
3 # XXX editing access maps?
4
5 require './postfix-lib.pl';
6
7 $access{'client'} || &error($text{'client_ecannot'});
8 &ui_print_header(undef, $text{'client_title'}, "");
9
10 $default = $text{'opts_default'};
11 $none = $text{'opts_none'};
12 $no_ = $text{'opts_no'};
13
14 print &ui_form_start("save_client.cgi", "post");
15 print &ui_table_start($text{'client_title'}, undef, 2);
16
17 # Parse current settings, by building a map from names to indexes
18 @opts = split(/[\s,]+/, &get_current_value('smtpd_client_restrictions'));
19 for(my $i=0; $i<@opts; $i++) {
20         $opts{$opts[$i]} ||= [ ];
21         push(@{$opts{$opts[$i]}}, $i);
22         }
23
24 # Add binary restrictions to list
25 @grid = ( );
26 %done = ( );
27 foreach $r (&list_client_restrictions()) {
28         push(@grid, &ui_checkbox("client", $r, $text{'sasl_'.$r},
29                                  defined($opts{$r})), undef);
30         $done{$r} = 1;
31         }
32
33 # Add restrictions with values
34 foreach $r (&list_multi_client_restrictions()) {
35         @v = @{$opts{$r}};
36         $vals = undef;
37         if (scalar(@v)) {
38                 $vals = join(" ", map { $opts[$_+1] } @v);
39                 }
40         push(@grid, &ui_checkbox("client", $r, $text{'sasl_'.$r},
41                                  scalar(@v)),
42                     &ui_textbox("value_$r", $vals, 60).
43                     ($r eq "check_client_access" ?
44                         " ".&map_chooser_button("value_$r", $r) : ""));
45         $done{$r} = 1;
46         foreach $v (@v) {
47                 $done{$opts[$v+1]} = 1;
48                 }
49         if ($r eq "check_client_access" && @v) {
50                 # Can show client access map
51                 $has_client_access = 1;
52                 }
53         }
54
55 # Show text field for the rest
56 @rest = grep { !$done{$_} } @opts;
57 if (@rest) {
58         push(@grid, &ui_checkbox("other", 1, $text{'client_other'}, 1),
59                     &ui_textbox("other_list", join(" ", @rest), 40));
60         }
61
62 # Show field
63 print &ui_table_row($text{'client_restrict'},
64         &ui_radio("client_def", @opts ? 0 : 1,
65                   [ [ 1, $text{'client_restrict1'} ],
66                     [ 0, $text{'client_restrict0'} ] ])."<br>\n".
67         &ui_grid_table(\@grid, 2));
68
69 print &ui_table_end();
70 print &ui_form_end([ [ undef, $text{'save'} ] ]);
71
72 if ($has_client_access) {
73         print &ui_hr();
74         &generate_map_edit("smtpd_client_restrictions:check_client_access",
75                 $text{'map_click'}." ".
76                 "<font size=\"-1\">".&hlink("$text{'help_map_format'}",
77                         "access")."</font>\n<br>\n", 1,
78                 $text{'mapping_client'}, $text{'header_value'});
79         }
80
81 &ui_print_footer("", $text{'index_return'});