Handle hostnames with upper-case letters
[webmin.git] / frox / save_cache.cgi
1 #!/usr/local/bin/perl
2 # Save caching options
3
4 require './frox-lib.pl';
5 &ReadParse();
6 &error_setup($text{'cache_err'});
7 $conf = &get_config();
8
9 if (!$in{'CacheModule'}) {
10         &save_directive($conf, "CacheModule", [ ]);
11         }
12 elsif ($in{'CacheModule'} eq 'local') {
13         &save_directive($conf, "CacheModule", [ "local" ]);
14         &save_textbox($conf, "CacheSize", \&check_size);
15         }
16 else {
17         &save_directive($conf, "CacheModule", [ "http" ]);
18         &save_textbox($conf, "HTTPProxy", \&check_proxy);
19         &save_textbox($conf, "MinCacheSize", \&check_size);
20         }
21
22 &save_yesno($conf, "StrictCaching");
23 &save_yesno($conf, "CacheOnFQDN");
24 &save_yesno($conf, "CacheAll");
25
26 &save_opt_textbox($conf, "VirusScanner", \&check_scanner);
27 &save_opt_textbox($conf, "VSOK", \&check_int);
28 &save_opt_textbox($conf, "VSProgressMsgs", \&check_int);
29
30 &lock_file($config{'frox_conf'});
31 &flush_file_lines();
32 &unlock_file($config{'frox_conf'});
33 &webmin_log("cache");
34 &redirect("");
35
36 sub check_size
37 {
38 return $_[0] =~ /^\d+$/ ? undef : $text{'cache_esize'};
39 }
40
41 sub check_proxy
42 {
43 return $_[0] =~ /^(\S+):(\d+)$/ && &to_ipaddress($1) ?
44         undef : $text{'cache_eproxy'};
45 }
46
47 sub check_scanner
48 {
49 return $_[0] =~ /^"([^"]+)"/ && -x $1 ? undef :
50        $_[0] =~ /^(\S+)/ && -x $1 ? undef : $text{'cache_escanner'};
51 }
52
53 sub check_int
54 {
55 return $_[0] =~ /^\d+$/ ? undef : $text{'cache_eint'};
56 }
57