2 # Save or delete a refresh pattern
4 require './squid-lib.pl';
5 $access{'refresh'} || &error($text{'refresh_ecannot'});
7 &lock_file($config{'squid_conf'});
9 &error_setup($text{'refresh_err'});
11 @refresh = &find_config("refresh_pattern", $conf);
12 if (defined($in{'index'})) {
13 $h = $conf->[$in{'index'}];
16 # delete this restriction
17 splice(@refresh, &indexof($h, @refresh), 1);
21 $in{'re'} =~ /^\S+$/ || &error($text{'refresh_ere'});
22 $in{'min'} =~ /^\d+$/ || &error($text{'refresh_emin'});
23 $in{'max'} =~ /^\d+$/ || &error($text{'refresh_emax'});
24 $in{'pc'} =~ /^\d+$/ && $in{'pc'} >= 0 && $in{'pc'} <= 100 ||
25 &error($text{'refresh_epc'});
26 push(@vals, "-i") if ($in{'caseless'});
27 push(@vals, $in{'re'}, $in{'min'}, $in{'pc'}.'%', $in{'max'});
28 push(@vals, split(/\0/, $in{'options'}));
29 $newr = { 'name' => 'refresh_pattern',
31 $idx = &indexof($h, @refresh);
32 if ($h) { splice(@refresh, &indexof($h, @refresh), 1, $newr); }
33 else { push(@refresh, $newr); }
35 &save_directive($conf, "refresh_pattern", \@refresh);
37 &unlock_file($config{'squid_conf'});
38 &webmin_log($in{'delete'} ? 'delete' : $h ? 'modify' : 'create',
39 "refresh", $in{'re'});
40 &redirect("list_refresh.cgi");