Handle hostnames with upper-case letters
[webmin.git] / squid / save_headeracc.cgi
1 #!/usr/local/bin/perl
2 # Save or delete an HTTP header access control rule
3
4 require './squid-lib.pl';
5 $access{'headeracc'} || &error($text{'headeracc_ecannot'});
6 &ReadParse();
7 &lock_file($config{'squid_conf'});
8 $conf = &get_config();
9 &error_setup($text{'headeracc_err'});
10
11 @headeracc = &find_config($in{'type'}, $conf);
12 if (defined($in{'index'})) {
13         $h = $conf->[$in{'index'}];
14         }
15 if ($in{'delete'}) {
16         # delete this restriction
17         splice(@headeracc, &indexof($h, @headeracc), 1);
18         }
19 else {
20         # update or create
21         $in{'name'} =~ /^[a-z0-9\.\-\_]+$/i || &error($text{'header_ename'});
22         @vals = ( $in{'name'}, $in{'action'} );
23         foreach $y (split(/\0/, $in{'yes'})) { push(@vals, $y); }
24         foreach $n (split(/\0/, $in{'no'})) { push(@vals, "!$n"); }
25         $newh = { 'name' => $in{'type'}, 'values' => \@vals };
26         if ($h) { splice(@headeracc, &indexof($h, @headeracc), 1, $newh); }
27         else { push(@headeracc, $newh); }
28         }
29 &save_directive($conf, $in{'type'}, \@headeracc);
30 &flush_file_lines();
31 &unlock_file($config{'squid_conf'});
32 &webmin_log($in{'delete'} ? 'delete' : $h ? 'modify' : 'create',
33             "headeracc", $in{'name'});
34 &redirect("list_headeracc.cgi");
35