Gro├čes Update:
[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
18require 'CONFIG_ROOT/general-functions.pl';
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';
35$logsettings{'REMOTELOG_ADDR'} = '';
36$logsettings{'ACTION'} = '';
37&Header::getcgihash(\%logsettings);
38
39if ($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/restartsyslogd') == 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
81map ($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
88if ($errormessage) {
89 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
90 print "<font class='base'>$errormessage&nbsp;</font>\n";
91 &Header::closebox();
92}
93
94print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
95
96&Header::openbox('100%', 'left', $Lang::tr{'log viewing options'});
97print <<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'>
104END
105;
106foreach my $vs (@VS) {
107 print "\t<option value='$vs' $selected{'LOGVIEW_VIEWSIZE'}{$vs}>$vs</option>\n";
108}
109print <<END
110 </select></td>
111</tr>
112</table>
113END
114;
115&Header::closebox();
116
117&Header::openbox('100%', 'left', $Lang::tr{'log summaries'});
118print <<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>
132END
133;
134&Header::closebox();
135
136&Header::openbox('100%', 'left', $Lang::tr{'remote logging'});
137print <<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>
144END
145;
146&Header::closebox();
147
148
149
150print <<END
151<div align='center'>
152<table width='60%'>
153<tr>
154 <td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
155</tr>
156</table>
157</div>
158END
159;
160
161print "</form>\n";
162
163&Header::closebigbox();
164
165&Header::closepage();