Handle hostnames with upper-case letters
[webmin.git] / squid / save_mem.cgi
1 #!/usr/local/bin/perl
2 # save_mem.cgi
3 # Save memory usage options
4
5 require './squid-lib.pl';
6 $access{'musage'} || &error($text{'emem_ecannot'});
7 &ReadParse();
8 &lock_file($config{'squid_conf'});
9 $conf = &get_config();
10 $whatfailed = $text{'smem_ftsmo'};
11
12 if ($squid_version < 2) {
13         &save_opt("cache_mem", \&check_size, $conf);
14         &save_opt("cache_swap", \&check_size, $conf);
15         }
16 else {
17         &save_opt_bytes("cache_mem", $conf);
18         &save_opt("fqdncache_size", \&check_size, $conf);
19         }
20 if ($squid_version < 2.5) {
21         &save_opt("cache_mem_high", \&check_high, $conf);
22         &save_opt("cache_mem_low", \&check_low, $conf);
23         }
24 &save_opt("cache_swap_high", \&check_high, $conf);
25 &save_opt("cache_swap_low", \&check_low, $conf);
26 if ($squid_version < 2) {
27         &save_opt("maximum_object_size", \&check_obj_size, $conf);
28         }
29 else {
30         &save_opt_bytes("maximum_object_size", $conf);
31         }
32 &save_opt("ipcache_size", \&check_size, $conf);
33 &save_opt("ipcache_high", \&check_high, $conf);
34 &save_opt("ipcache_low", \&check_low, $conf);
35 if ($squid_version >= 2.4) {
36         &save_choice("cache_replacement_policy", '', $conf);
37         &save_choice("memory_replacement_policy", '', $conf);
38         }
39 &flush_file_lines();
40 &unlock_file($config{'squid_conf'});
41 &webmin_log("mem", undef, undef, \%in);
42 &redirect("");
43
44 sub check_size
45 {
46 return $_[0] =~ /^\d+$/ ? undef : &text('smem_emsg1',$_[0]);
47 }
48
49 sub check_high
50 {
51 return $_[0] =~ /^\d+$/ && $_[0] > 0 && $_[0] <= 100
52                 ? undef : &text('smem_emsg2',$_[0]);
53 }
54
55 sub check_low
56 {
57 return $_[0] =~ /^\d+$/ && $_[0] > 0 && $_[0] <= 100
58                 ? undef : &text('smem_emsg3',$_[0]);
59 }
60
61 sub check_obj_size
62 {
63 return $_[0] =~ /^\d+$/ ? undef : &text('smem_emsg4',$_[0]);
64 }
65