1#!/usr/local/bin/perl 2# edit_logs.cgi 3# A form for editing logging options 4 5use strict; 6use warnings; 7our (%text, %in, %access, $squid_version, %config); 8require './squid-lib.pl'; 9$access{'logging'} || &error($text{'elogs_ecannot'}); 10&ui_print_header(undef, $text{'elogs_header'}, "", "edit_logs", 0, 0, 0, &restart_button()); 11my $conf = &get_config(); 12 13print &ui_form_start("save_logs.cgi", "post"); 14print &ui_table_start($text{'elogs_lalo'}, "width=100%", 4); 15 16if ($squid_version < 2.6) { 17 # Just a single logging directive 18 print &opt_input($text{'elogs_alf'}, "cache_access_log", $conf, 19 $text{'default'}, 50); 20 } 21else { 22 # Supports definition of log formats and files 23 my @logformat = &find_config("logformat", $conf); 24 my $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 my $i = 0; 30 foreach my $f (@logformat, { 'values' => [] }) { 31 my ($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 &ui_table_row($text{'elogs_logformat'}, $ltable, 3); 40 41 # Show log files 42 my @access = &find_config("access_log", $conf); 43 my $atable = &ui_columns_start([ $text{'elogs_afile'}, 44 $text{'elogs_afmt'}, 45 $text{'elogs_aacls'} ]); 46 $i = 0; 47 foreach my $a (@access, { 'values' => [] }) { 48 my ($afile, $afmt, @aacls) = @{$a->{'values'}}; 49 $atable .= &ui_columns_row([ 50 &ui_radio("afile_def_$i", 51 !$afile ? 1 : $afile eq "none" ? 2 : 0, 52 [ [ 1, $text{'elogs_notset'} ], 53 [ 2, $text{'elogs_dont'} ], 54 [ 0, &text('elogs_file', 55 &ui_textbox("afile_$i", 56 $afile eq "none" ? "" : $afile, 57 30)) ] ]), 58 &ui_select("afmt_$i", $afmt, 59 [ [ "", "<".$text{'default'}.">" ], 60 [ "squid", "<".$text{'elogs_squid'}.">" ], 61 map { [ $_->{'values'}->[0] ] } @logformat ], 62 1, 0, 1), 63 &ui_textbox("aacls_$i", join(" ", @aacls), 20) 64 ]); 65 $i++; 66 } 67 $atable .= &ui_columns_end(); 68 print &ui_table_row($text{'elogs_access'}, $atable, 3); 69 } 70 71print &opt_input($text{'elogs_dlf'}, "cache_log", $conf, $text{'default'}, 50); 72 73my $cslv = &find_config("cache_store_log", $conf); 74my $cslm = $cslv->{'value'} eq 'none' ? 2 : $cslv->{'value'} ? 0 : 1; 75print &ui_table_row($text{'elogs_slf'}, 76 &ui_radio("cache_store_log_def", $cslm, 77 [ [ 1, $text{'default'} ], 78 [ 2, $text{'elogs_none'} ], 79 [ 0, &ui_textbox("cache_store_log", 80 $cslm == 0 ? $cslv->{'value'} : "", 50) ] ])); 81 82print &opt_input($text{'elogs_cmf'}, "cache_swap_log", $conf, 83 $text{'default'}, 50); 84 85print &choice_input($text{'elogs_uhlf'}, "emulate_httpd_log", $conf, 86 "off", $text{'yes'}, "on", $text{'no'}, "off"); 87print &choice_input($text{'elogs_lmh'}, "log_mime_hdrs", $conf, 88 "off", $text{'yes'}, "on", $text{'no'}, "off"); 89 90print &opt_input($text{'elogs_ualf'}, "useragent_log", $conf, 91 $text{'none'}, 20); 92print &opt_input($text{'elogs_pf'}, "pid_filename", $conf, 93 $text{'default'}, 20); 94 95if ($squid_version >= 2.2) { 96 my @ident = &find_config("ident_lookup_access", $conf); 97 my (%ila, $bad_ident); 98 foreach my $i (@ident) { 99 my @v = @{$i->{'values'}}; 100 if ($v[0] eq "allow") { 101 %ila = map { $_, 1 } @v[1..$#v]; 102 } 103 elsif ($v[0] eq "deny" && $v[1] ne "all") { 104 $bad_ident++; 105 } 106 } 107 if (!$bad_ident) { 108 my @acls = &find_config("acl", $conf); 109 unshift(@acls, { 'values' => [ 'all' ] }) 110 if ($squid_version >= 3); 111 my (%doneacl, @cbs); 112 foreach my $acl (@acls) { 113 my $aclv = $acl->{'values'}->[0]; 114 next if ($doneacl{$aclv}++); 115 push(@cbs, &ui_checkbox("ident_lookup_access", $aclv, 116 $aclv, $ila{$aclv})); 117 } 118 print &ui_table_row($text{'elogs_prilfa'}, 119 join("\n", @cbs), 3); 120 } 121 else { print "<input type=hidden name=complex_ident value=1>\n"; } 122 print "<tr>\n"; 123 print &opt_time_input($text{'elogs_rit'}, "ident_timeout", 124 $conf, $text{'default'}, 6); 125 } 126else { 127 print &choice_input($text{'elogs_dril'}, "ident_lookup", $conf, 128 "off", $text{'yes'}, "on", $text{'no'}, "off"); 129 } 130print &choice_input($text{'elogs_lfh'}, "log_fqdn", $conf, 131 "off", $text{'yes'}, "on", $text{'no'}, "off"); 132 133print &opt_input($text{'elogs_ln'}, "client_netmask", $conf, 134 $text{'default'}, 15); 135print &opt_input($text{'elogs_do'}, "debug_options", $conf, 136 $text{'default'}, 15); 137 138if ($squid_version >= 2) { 139 print &opt_input($text{'elogs_mht'}, "mime_table", 140 $conf, $text{'default'}, 20); 141 } 142 143print &ui_table_end(); 144print &ui_form_end([ [ undef, $text{'buttsave'} ] ]); 145 146&ui_print_footer("", $text{'elogs_return'}); 147 148