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