Always enable asynchronous logging
[ipfire-2.x.git] / html / cgi-bin / logs.cgi / config.dat
1 #!/usr/bin/perl
2 #
3 # IPFire CGIs
4 #
5 # This code is distributed under the terms of the GPL
6 #
7 # (c) The IPFire Team
8 #
9 # $Id: config.dat,v 1.2.2.10 2005/06/14 12:32:07 eoberlander Exp $
10 #
11
12 use strict;
13
14 # enable only the following on debugging purpose
15 #use warnings;
16 #use CGI::Carp 'fatalsToBrowser';
17
18 require '/var/ipfire/general-functions.pl';
19 require "${General::swroot}/lang.pl";
20 require "${General::swroot}/header.pl";
21
22 my %logsettings=();
23 my %checked=();
24 my %selected=();
25 my $errormessage='';
26
27 &Header::showhttpheaders();
28
29 $logsettings{'LOGVIEW_REVERSE'} = 'off';
30 $logsettings{'LOGVIEW_VIEWSIZE'} = '150';
31 $logsettings{'LOGWATCH_LEVEL'} = 'Low';
32 $logsettings{'LOGWATCH_KEEP'} = '56';
33 my @VS = ('15','50','100','150','250','500');
34 $logsettings{'ENABLE_REMOTELOG'} = 'off';
35 $logsettings{'REMOTELOG_ADDR'} = '';
36 $logsettings{'ACTION'} = '';
37 &Header::getcgihash(\%logsettings);
38
39 if ($logsettings{'ACTION'} eq $Lang::tr{'save'})
40 {
41   if ($logsettings{'ENABLE_REMOTELOG'} eq 'on')
42   {
43     unless ( &General::validfqdn($logsettings{'REMOTELOG_ADDR'}) ||
44              &General::validip  ($logsettings{'REMOTELOG_ADDR'}))
45     {
46       $errormessage = $Lang::tr{'invalid logserver address'};
47     }
48   }
49   unless ($logsettings{'LOGWATCH_KEEP'} =~ /^\d+$/)
50   {
51     $errormessage = $Lang::tr{'invalid keep time'};
52   }
53   unless ($logsettings{'LOGWATCH_LEVEL'} =~ /^Low|Med|High$/)
54   {
55     $errormessage = $Lang::tr{'invalid input'};
56   }
57   unless ($errormessage)
58   {
59     &General::writehash("${General::swroot}/logging/settings", \%logsettings);
60     system('/usr/local/bin/syslogdctrl') == 0
61       or $errormessage = "$Lang::tr{'bad return code'} " . $?/256;
62   }
63
64 }
65
66 &General::readhash("${General::swroot}/logging/settings", \%logsettings);
67
68 $checked{'ENABLE_REMOTELOG'}{'off'} = '';
69 $checked{'ENABLE_REMOTELOG'}{'on'} = '';
70 $checked{'ENABLE_REMOTELOG'}{$logsettings{'ENABLE_REMOTELOG'}} = "checked='checked'";
71
72 $checked{'LOGVIEW_REVERSE'}{'off'} = '';
73 $checked{'LOGVIEW_REVERSE'}{'on'} = '';
74 $checked{'LOGVIEW_REVERSE'}{$logsettings{'LOGVIEW_REVERSE'}} = "checked='checked'";
75
76 $selected{'LOGWATCH_LEVEL'}{'Low'} = '';
77 $selected{'LOGWATCH_LEVEL'}{'Med'} = '';
78 $selected{'LOGWATCH_LEVEL'}{'High'} = '';
79 $selected{'LOGWATCH_LEVEL'}{$logsettings{'LOGWATCH_LEVEL'}} = "selected='selected'";
80
81 map ($selected{'LOGVIEW_VIEWSIZE'}{$_} = '', @VS);
82 $selected{'LOGVIEW_VIEWSIZE'}{$logsettings{'LOGVIEW_VIEWSIZE'}} = "selected='selected'";
83
84 &Header::openpage($Lang::tr{'log settings'}, 1, '');
85
86 &Header::openbigbox('100%', 'left', '', $errormessage);
87
88 if ($errormessage) {
89   &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
90   print "<font class='base'>$errormessage&nbsp;</font>\n";
91   &Header::closebox();
92 }
93
94 print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
95
96 &Header::openbox('100%', 'left', $Lang::tr{'log viewing options'});
97 print <<END
98 <table width='100%'>
99 <tr>
100         <td><input type='checkbox' name='LOGVIEW_REVERSE' $checked{'LOGVIEW_REVERSE'}{'on'} /></td>
101         <td class='base' width='50%'>$Lang::tr{'reverse sort'}</td>
102         <td class='base' width='25%' align='right'>$Lang::tr{'log lines per page'}:&nbsp;</td>
103         <td width='25%'><select name='LOGVIEW_VIEWSIZE'>
104 END
105 ;
106 foreach my $vs (@VS) {
107     print "\t<option value='$vs' $selected{'LOGVIEW_VIEWSIZE'}{$vs}>$vs</option>\n";
108 }
109 print <<END
110         </select></td>
111 </tr>
112 </table>
113 END
114 ;
115 &Header::closebox();
116
117 &Header::openbox('100%', 'left', $Lang::tr{'log summaries'});
118 print <<END
119 <table width='100%'>
120 <tr>
121   <td class='base' width='50%'>$Lang::tr{'summaries kept'}&nbsp;
122   <input type='text' name='LOGWATCH_KEEP'
123   value='$logsettings{'LOGWATCH_KEEP'}' size='4' />&nbsp;$Lang::tr{'days'}</td>
124   <td>$Lang::tr{'detail level'}:</td><td>
125   <select name='LOGWATCH_LEVEL'>
126   <option value='Low' $selected{'LOGWATCH_LEVEL'}{'Low'}>$Lang::tr{'low'}</option>
127   <option value='Med' $selected{'LOGWATCH_LEVEL'}{'Med'}>$Lang::tr{'medium'}</option>
128   <option value='High' $selected{'LOGWATCH_LEVEL'}{'High'}>$Lang::tr{'high'}</option>
129   </select></td>
130 </tr>
131 </table>
132 END
133 ;
134 &Header::closebox();
135
136 &Header::openbox('100%', 'left', $Lang::tr{'remote logging'});
137 print <<END
138 <table width='100%'>
139 <tr>
140   <td class='base'>$Lang::tr{'enabled'}</td><td><input type='checkbox' name='ENABLE_REMOTELOG' $checked{'ENABLE_REMOTELOG'}{'on'} /></td>
141   <td>$Lang::tr{'log server address'}</td><td><input type='text' name='REMOTELOG_ADDR' value='$logsettings{'REMOTELOG_ADDR'}' /></td>
142 </tr>
143 </table>
144 END
145 ;
146 &Header::closebox();
147
148 print <<END
149 <div align='center'>
150 <table width='60%'>
151 <tr>
152   <td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
153 </tr>
154 </table>
155 </div>
156 END
157 ;
158
159 print "</form>\n";
160
161 &Header::closebigbox();
162
163 &Header::closepage();