2 # Save or delete an HTTP header access control rule
4 require './squid-lib.pl';
5 $access{'headeracc'} || &error($text{'headeracc_ecannot'});
7 &lock_file($config{'squid_conf'});
9 &error_setup($text{'headeracc_err'});
11 @headeracc = &find_config($in{'type'}, $conf);
12 if (defined($in{'index'})) {
13 $h = $conf->[$in{'index'}];
16 # delete this restriction
17 splice(@headeracc, &indexof($h, @headeracc), 1);
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); }
29 &save_directive($conf, $in{'type'}, \@headeracc);
31 &unlock_file($config{'squid_conf'});
32 &webmin_log($in{'delete'} ? 'delete' : $h ? 'modify' : 'create',
33 "headeracc", $in{'name'});
34 &redirect("list_headeracc.cgi");