Handle hostnames with upper-case letters
[webmin.git] / squid / edit_delay.cgi
1 #!/usr/local/bin/perl
2 # edit_delay.cgi
3 # Displays a list of existing delay pools
4
5 require './squid-lib.pl';
6 $access{'delay'} || &error($text{'delay_ecannot'});
7 &ui_print_header(undef, $text{'delay_title'}, "", "edit_delay", 0, 0, 0, &restart_button());
8 $conf = &get_config();
9
10 # Display all known delay pools
11 $pools = &find_value("delay_pools", $conf);
12 @links = ( &select_all_link("d"),
13            &select_invert_link("d"),
14            "<a href='edit_pool.cgi?new=1'>$text{'delay_add'}</a>" );
15 if ($pools) {
16         @pools = sort { $a->{'values'}->[0] <=> $b->{'values'}->[0] }
17                       &find_config("delay_class", $conf);
18         @params = &find_config("delay_parameters", $conf);
19         print &ui_form_start("delete_pools.cgi", "post");
20         print &ui_links_row(\@links);
21         @tds = ( "width=5" );
22         print &ui_columns_start([ "",
23                                   $text{'delay_num'},
24                                   $text{'delay_class'},
25                                   $text{'delay_agg'},
26                                   $text{'delay_ind'},
27                                   $text{'delay_net'},
28                                   $squid_version >= 3 ? (
29                                         $text{'delay_user'},
30                                         $text{'delay_tag'} ) : ( ),
31                                 ], 100, 0, \@tds);
32         foreach $p (@pools) {
33                 local ($pr) = grep { $_->{'values'}->[0] ==
34                                      $p->{'values'}->[0] } @params;
35                 local @cols;
36                 push(@cols, "<a href='edit_pool.cgi?idx=$p->{'values'}->[0]'>".
37                             "$p->{'values'}->[0]</a>");
38                 push(@cols, $text{"delay_class_$p->{'values'}->[1]"});
39                 if ($p->{'values'}->[1] == 5) {
40                         push(@cols, "", "", "", "");
41                         push(@cols, &pool_param($pr->{'values'}->[1]));
42                         }
43                 else {
44                         push(@cols, &pool_param($pr->{'values'}->[1]));
45                         if ($p->{'values'}->[1] == 2) {
46                                 push(@cols, &pool_param($pr->{'values'}->[2]));
47                                 push(@cols, "");
48                                 }
49                         else {
50                                 push(@cols, &pool_param($pr->{'values'}->[3]));
51                                 push(@cols, &pool_param($pr->{'values'}->[2]));
52                                 }
53                         if ($squid_version >= 3) {
54                                 if ($p->{'values'}->[1] == 4) {
55                                         push(@cols, &pool_param(
56                                                 $pr->{'values'}->[4]));
57                                         }
58                                 else {
59                                         push(@cols, "");
60                                         }
61                                 push(@cols, "");
62                                 }
63                         }
64                 print &ui_checked_columns_row(\@cols, \@tds,
65                                               "d", $p->{'values'}->[0]);
66                 }
67         print &ui_columns_end();
68         print &ui_links_row(\@links);
69         print &ui_form_end([ [ "delete", $text{'delay_delete'} ] ]);
70         }
71 else {
72         print "<b>$text{'delay_none'}</b><p>\n";
73         print &ui_links_row([ $links[2] ]);
74         }
75
76 print "<form action=save_delay.cgi>\n";
77 print "<table border width=100%>\n";
78 print "<tr $tb> <td><b>$text{'delay_header'}</b></td> </tr>\n";
79 print "<tr $cb> <td><table width=100%>\n";
80
81 print "<tr>\n";
82 print &opt_input($text{'delay_initial'}, "delay_initial_bucket_level", $conf,
83                  $text{'default'}, 4, "%");
84 print "<td colspan=2 width=50%></td>\n";
85 print "</tr>\n";
86
87 print "</table></td></tr></table>\n";
88 print "<input type=submit value='$text{'save'}'></form>\n";
89
90 &ui_print_footer("", $text{'eicp_return'});
91
92 # pool_param(param)
93 sub pool_param
94 {
95 if ($_[0] =~ /^([0-9\-]+)\/([0-9\-]+)$/) {
96         return $1 == -1 ? $text{'delay_unlimited'} :
97                 &text('delay_param', "$1", "$2");
98         }
99 else {
100         return $_[0];   # huh?
101         }
102 }
103