Handle hostnames with upper-case letters
[webmin.git] / squid / save_misc.cgi
1 #!/usr/local/bin/perl
2 # save_misc.cgi
3 # Save miscellaneous options
4
5 require './squid-lib.pl';
6 $access{'miscopt'} || &error($text{'emisc_ecannot'});
7 &ReadParse();
8 &lock_file($config{'squid_conf'});
9 $conf = &get_config();
10 $whatfailed = $text{'smisc_ftso'};
11
12 &save_opt("dns_testnames", undef, $conf);
13 &save_opt("logfile_rotate", \&check_rotate, $conf);
14 &save_opt("append_domain", \&check_domain, $conf);
15 if ($squid_version < 2) {
16         &save_opt("ssl_proxy", \&check_proxy, $conf);
17         &save_opt("passthrough_proxy", \&check_proxy, $conf);
18         }
19 &save_opt("err_html_text", undef, $conf);
20 &save_choice("client_db", "on", $conf);
21 &save_choice("forwarded_for", "on", $conf);
22 &save_choice("log_icp_queries", "on", $conf);
23 &save_opt("minimum_direct_hops", \&check_hops, $conf);
24 if ($squid_version >= 2.2 && $squid_version < 2.5) {
25         $m = $in{'anon_mode'};
26         if ($m == 0) {
27                 &save_directive($conf, "anonymize_headers", [ ]);
28                 }
29         else {
30                 &save_directive($conf, "anonymize_headers",
31                         [ { 'name' => 'anonymize_headers',
32                             'values' => [ $m==1 ? "allow" : "deny",
33                                           $m==1 ? $in{'anon_allow'}
34                                                 : $in{'anon_deny'} ] } ]);
35                 }
36         }
37 elsif ($squid_version < 2.2) {
38         &save_choice("http_anonymizer", "off", $conf);
39         }
40 &save_opt("fake_user_agent", undef, $conf);
41 &save_choice("memory_pools", "on", $conf);
42 if ($squid_version < 2.6) {
43         if ($in{'accel'} == 0) {
44                 &save_directive($conf, "httpd_accel_host", [ ]);
45                 }
46         else {
47                 local $v = $in{'accel'} == 1 ? "virtual" : $in{"httpd_accel_host"};
48                 &save_directive($conf, "httpd_accel_host",
49                                 [ { 'name' => "httpd_accel_host", 'values' => [$v] } ]);
50                 }
51         &save_opt("httpd_accel_port", undef, $conf);
52         &save_choice("httpd_accel_with_proxy", undef, $conf);
53         &save_choice("httpd_accel_uses_host_header", undef, $conf);
54         if ($squid_version >= 2.5) {
55                 &save_choice("httpd_accel_single_host", undef, $conf);
56                 }
57         }
58 if ($squid_version >= 2) {
59         &save_opt_bytes("memory_pools_limit", $conf);
60         }
61 if ($squid_version >= 2.3) {
62         &save_opt("wccp_router", undef, $conf);
63         &save_opt("wccp_incoming_address", undef, $conf);
64         &save_opt("wccp_outgoing_address", undef, $conf);
65         }
66 &flush_file_lines();
67 &unlock_file($config{'squid_conf'});
68 &webmin_log("misc", undef, undef, \%in);
69 &redirect("");
70
71 sub check_rotate
72 {
73 return $_[0] =~ /^\d+$/ ? undef : &text('smisc_emsg1',$_[0]);
74 }
75
76 sub check_domain
77 {
78 return $_[0] =~ /^[A-z0-9\.\-]+$/ ? undef : &text('smisc_emsg2',$_[0]); 
79 }
80
81 sub check_proxy
82 {
83 return $_[0] =~ /^\S+$/ ? undef : &text('smisc_emsg3',$_[0]); 
84 }
85
86 sub check_hops
87 {
88 return $_[0] =~ /^\d+$/ ? undef : &text('smisc_emsg4',$_[0]); 
89 }
90