Handle hostnames with upper-case letters
[webmin.git] / squid / edit_logs.cgi
1 #!/usr/local/bin/perl
2 # edit_logs.cgi
3 # A form for editing logging options
4
5 require './squid-lib.pl';
6 $access{'logging'} || &error($text{'elogs_ecannot'});
7 &ui_print_header(undef, $text{'elogs_header'}, "", "edit_logs", 0, 0, 0, &restart_button());
8 $conf = &get_config();
9
10 print "<form action=save_logs.cgi>\n";
11 print "<table border width=100%>\n";
12 print "<tr $tb> <td><b>$text{'elogs_lalo'}</b></td> </tr>\n";
13 print "<tr $cb> <td><table width=100%>\n";
14
15 if ($squid_version < 2.6) {
16         # Just a single logging directive
17         print "<tr>\n";
18         print &opt_input($text{'elogs_alf'}, "cache_access_log", $conf, $text{'default'}, 50);
19         print "</tr>\n";
20         }
21 else {
22         # Supports definition of log formats and files
23         @logformat = &find_config("logformat", $conf);
24         $ltable = &ui_radio("logformat_def", @logformat ? 0 : 1,
25                             [ [ 1, $text{'elogs_logformat1'} ],
26                               [ 0, $text{'elogs_logformat0'} ] ])."<br>\n";
27         $ltable .= &ui_columns_start([ $text{'elogs_fname'},
28                                       $text{'elogs_ffmt'} ]);
29         $i = 0;
30         foreach $f (@logformat, { }) {
31                 ($fname, @ffmt) = @{$f->{'values'}};
32                 $ltable .= &ui_columns_row([
33                         &ui_textbox("fname_$i", $fname, 20),
34                         &ui_textbox("ffmt_$i", join(" ", @ffmt), 60)
35                         ]);
36                 $i++;
37                 }
38         $ltable .= &ui_columns_end();
39         print "<tr> <td valign=top><b>$text{'elogs_logformat'}</b></td>\n";
40         print "<td colspan=3>$ltable</td> </tr>\n";
41
42         # Show log files
43         @access = &find_config("access_log", $conf);
44         $atable = &ui_columns_start([ $text{'elogs_afile'},
45                                       $text{'elogs_afmt'},
46                                       $text{'elogs_aacls'} ]);
47         $i = 0;
48         foreach $a (@access, { }) {
49                 ($afile, $afmt, @aacls) = @{$a->{'values'}};
50                 $atable .= &ui_columns_row([
51                   &ui_radio("afile_def_$i",
52                             !$afile ? 1 : $afile eq "none" ? 2 : 0,
53                             [ [ 1, $text{'elogs_notset'} ],
54                               [ 2, $text{'elogs_dont'} ],
55                               [ 0, &text('elogs_file',
56                                     &ui_textbox("afile_$i",
57                                                 $afile eq "none" ? "" : $afile,
58                                                 30)) ] ]),
59                   &ui_select("afmt_$i", $afmt,
60                              [ [ "", "&lt;".$text{'default'}."&gt;" ],
61                                map { [ $_->{'values'}->[0] ] } @logformat ]),
62                   &ui_textbox("aacls_$i", join(" ", @aacls), 20)
63                   ]);
64                 $i++;
65                 }
66         $atable .= &ui_columns_end();
67         print "<tr> <td valign=top><b>$text{'elogs_access'}</b></td>\n";
68         print "<td colspan=3>$atable</td> </tr>\n";
69
70         print "<tr> <td colspan=4><hr></td> </tr>\n";
71         print "</table><table width=100%>\n";
72         }
73
74 print "<tr>\n";
75 print &opt_input($text{'elogs_dlf'}, "cache_log", $conf, $text{'default'}, 50);
76 print "</tr>\n";
77
78 print "<tr>\n";
79 $cslv = &find_config("cache_store_log", $conf);
80 $cslm = $cslv->{'value'} eq 'none' ? 2 : $cslv->{'value'} ? 0 : 1;
81 print "<td valign=top><b>$text{'elogs_slf'}</b></td>\n";
82 print "<td nowrap colspan=3>\n";
83 printf "<input type=radio name=cache_store_log_def value=1 %s> %s\n",
84         $cslm == 1 ? "checked" : "", $text{'default'};
85 printf "<input type=radio name=cache_store_log_def value=2 %s> %s\n",
86         $cslm == 2 ? "checked" : "", $text{'elogs_none'};
87 printf "<input type=radio name=cache_store_log_def value=0 %s>\n",
88         $cslm == 0 ? "checked" : "";
89 printf "<input name=cache_store_log size=50 value=\"%s\"></td>\n",
90         $cslm == 0 ? $cslv->{'value'} : "";
91 print "</tr>\n";
92
93 print "<tr>\n";
94 print &opt_input($text{'elogs_cmf'}, "cache_swap_log", $conf, $text{'default'}, 50);
95 print "</tr>\n";
96
97 print "<tr>\n";
98 print &choice_input($text{'elogs_uhlf'}, "emulate_httpd_log", $conf,
99                     "off", $text{'yes'}, "on", $text{'no'}, "off");
100 print &choice_input($text{'elogs_lmh'}, "log_mime_hdrs", $conf,
101                     "off", $text{'yes'}, "on", $text{'no'}, "off");
102 print "</tr>\n";
103
104 print "<tr>\n";
105 print &opt_input($text{'elogs_ualf'}, "useragent_log", $conf, $text{'none'}, 20);
106 print &opt_input($text{'elogs_pf'}, "pid_filename", $conf, $text{'default'}, 20);
107 print "</tr>\n";
108
109 if ($squid_version >= 2.2) {
110         @ident = &find_config("ident_lookup_access", $conf);
111         foreach $i (@ident) {
112                 local @v = @{$i->{'values'}};
113                 if ($v[0] eq "allow") { map { $ila{$_}++ } @v[1..$#v]; }
114                 elsif ($v[0] eq "deny" && $v[1] ne "all") { $bad_ident++; }
115                 }
116         if (!$bad_ident) {
117                 print "<tr><td valign=top><b>$text{'elogs_prilfa'}</b></td> <td colspan=3>\n";
118                 @acls = &find_config("acl", $conf);
119                 unshift(@acls, { 'values' => [ 'all' ] })
120                         if ($squid_version >= 3);
121                 foreach $acl (@acls) {
122                         $aclv = $acl->{'values'}->[0];
123                         next if ($doneacl{$aclv}++);
124                         printf "<input type=checkbox name=ident_lookup_access ".
125                                "value=$aclv %s>$aclv\n",
126                                 $ila{$aclv} ? "checked" : "";
127                         }
128                 print "</td> </tr>\n";
129                 }
130         else { print "<input type=hidden name=complex_ident value=1>\n"; }
131         print "<tr>\n";
132         print &opt_time_input($text{'elogs_rit'}, "ident_timeout",
133                               $conf, $text{'default'}, 6);
134         }
135 else {
136         print "<tr>\n";
137         print &choice_input($text{'elogs_dril'}, "ident_lookup", $conf,
138                             "off", $text{'yes'}, "on", $text{'no'}, "off");
139         }
140 print &choice_input($text{'elogs_lfh'}, "log_fqdn", $conf,
141                     "off", $text{'yes'}, "on", $text{'no'}, "off");
142 print "</tr>\n";
143
144 print "<tr>\n";
145 print &opt_input($text{'elogs_ln'}, "client_netmask", $conf, $text{'default'}, 15);
146 print &opt_input($text{'elogs_do'}, "debug_options", $conf, $text{'default'}, 15);
147 print "</tr>\n";
148
149 if ($squid_version >= 2) {
150         print "<tr>\n";
151         print &opt_input($text{'elogs_mht'}, "mime_table",
152                          $conf, $text{'default'}, 20);
153         print "</tr>\n";
154         }
155
156 print "</table></td></tr></table>\n";
157 print "<input type=submit value=$text{'buttsave'}></form>\n";
158
159 &ui_print_footer("", $text{'elogs_return'});
160