]> git.ipfire.org Git - ipfire-2.x.git/blob - html/cgi-bin/logs.cgi/config.dat
Hardcode theme to ipfire
[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{'REMOTELOG_PROTOCOL'} = 'udp';
37 $logsettings{'ACTION'} = '';
38 &Header::getcgihash(\%logsettings);
39
40 if ($logsettings{'ACTION'} eq $Lang::tr{'save'})
41 {
42 if ($logsettings{'ENABLE_REMOTELOG'} eq 'on')
43 {
44 unless ( &General::validfqdn($logsettings{'REMOTELOG_ADDR'}) ||
45 &General::validip ($logsettings{'REMOTELOG_ADDR'}))
46 {
47 $errormessage = $Lang::tr{'invalid logserver address'};
48 }
49 unless ($logsettings{'REMOTELOG_PROTOCOL'} =~ /^udp|tcp$/)
50 {
51 $errormessage = $Lang::tr{'invalid logserver protocol'};
52 }
53 }
54 unless ($logsettings{'LOGWATCH_KEEP'} =~ /^\d+$/)
55 {
56 $errormessage = $Lang::tr{'invalid keep time'};
57 }
58 unless ($logsettings{'LOGWATCH_LEVEL'} =~ /^Low|Med|High$/)
59 {
60 $errormessage = $Lang::tr{'invalid input'};
61 }
62 unless ($errormessage)
63 {
64 &General::writehash("${General::swroot}/logging/settings", \%logsettings);
65 system('/usr/local/bin/syslogdctrl') == 0
66 or $errormessage = "$Lang::tr{'bad return code'} " . $?/256;
67 }
68
69 }
70
71 &General::readhash("${General::swroot}/logging/settings", \%logsettings);
72
73 $checked{'ENABLE_REMOTELOG'}{'off'} = '';
74 $checked{'ENABLE_REMOTELOG'}{'on'} = '';
75 $checked{'ENABLE_REMOTELOG'}{$logsettings{'ENABLE_REMOTELOG'}} = "checked='checked'";
76
77 $selected{'REMOTELOG_PROTOCOL'}{'udp'} = '';
78 $selected{'REMOTELOG_PROTOCOL'}{'tcp'} == '';
79 $selected{'REMOTELOG_PROTOCOL'}{$logsettings{'REMOTELOG_PROTOCOL'}} = "selected='selected'";
80
81 $checked{'LOGVIEW_REVERSE'}{'off'} = '';
82 $checked{'LOGVIEW_REVERSE'}{'on'} = '';
83 $checked{'LOGVIEW_REVERSE'}{$logsettings{'LOGVIEW_REVERSE'}} = "checked='checked'";
84
85 $selected{'LOGWATCH_LEVEL'}{'Low'} = '';
86 $selected{'LOGWATCH_LEVEL'}{'Med'} = '';
87 $selected{'LOGWATCH_LEVEL'}{'High'} = '';
88 $selected{'LOGWATCH_LEVEL'}{$logsettings{'LOGWATCH_LEVEL'}} = "selected='selected'";
89
90 map ($selected{'LOGVIEW_VIEWSIZE'}{$_} = '', @VS);
91 $selected{'LOGVIEW_VIEWSIZE'}{$logsettings{'LOGVIEW_VIEWSIZE'}} = "selected='selected'";
92
93 &Header::openpage($Lang::tr{'log settings'}, 1, '');
94
95 &Header::openbigbox('100%', 'left', '', $errormessage);
96
97 if ($errormessage) {
98 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
99 print "<font class='base'>$errormessage&nbsp;</font>\n";
100 &Header::closebox();
101 }
102
103 print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
104
105 &Header::openbox('100%', 'left', $Lang::tr{'log viewing options'});
106 print <<END
107 <table width='100%'>
108 <tr>
109 <td><input type='checkbox' name='LOGVIEW_REVERSE' $checked{'LOGVIEW_REVERSE'}{'on'} /></td>
110 <td class='base' width='50%'>$Lang::tr{'reverse sort'}</td>
111 <td class='base' width='25%' align='right'>$Lang::tr{'log lines per page'}:&nbsp;</td>
112 <td width='25%'><select name='LOGVIEW_VIEWSIZE'>
113 END
114 ;
115 foreach my $vs (@VS) {
116 print "\t<option value='$vs' $selected{'LOGVIEW_VIEWSIZE'}{$vs}>$vs</option>\n";
117 }
118 print <<END
119 </select></td>
120 </tr>
121 </table>
122 END
123 ;
124 &Header::closebox();
125
126 &Header::openbox('100%', 'left', $Lang::tr{'log summaries'});
127 print <<END
128 <table width='100%'>
129 <tr>
130 <td class='base' width='50%'>$Lang::tr{'summaries kept'}&nbsp;
131 <input type='text' name='LOGWATCH_KEEP'
132 value='$logsettings{'LOGWATCH_KEEP'}' size='4' />&nbsp;$Lang::tr{'days'}</td>
133 <td>$Lang::tr{'detail level'}:</td><td>
134 <select name='LOGWATCH_LEVEL'>
135 <option value='Low' $selected{'LOGWATCH_LEVEL'}{'Low'}>$Lang::tr{'low'}</option>
136 <option value='Med' $selected{'LOGWATCH_LEVEL'}{'Med'}>$Lang::tr{'medium'}</option>
137 <option value='High' $selected{'LOGWATCH_LEVEL'}{'High'}>$Lang::tr{'high'}</option>
138 </select></td>
139 </tr>
140 </table>
141 END
142 ;
143 &Header::closebox();
144
145 &Header::openbox('100%', 'left', $Lang::tr{'remote logging'});
146 print <<END
147 <table width='100%'>
148 <tr>
149 <td class='base'>$Lang::tr{'enabled'}</td><td><input type='checkbox' name='ENABLE_REMOTELOG' $checked{'ENABLE_REMOTELOG'}{'on'} /></td>
150 <td>$Lang::tr{'log server address'}</td><td><input type='text' name='REMOTELOG_ADDR' value='$logsettings{'REMOTELOG_ADDR'}' /></td>
151 <td>$Lang::tr{'log server protocol'}</td><td>
152 <select name='REMOTELOG_PROTOCOL'>
153 <option value='udp' $selected{'REMOTELOG_PROTOCOL'}{'udp'}>$Lang::tr{'udp less overhead'}</option>
154 <option value='tcp' $selected{'REMOTELOG_PROTOCOL'}{'tcp'}>$Lang::tr{'tcp more reliable'}</option>
155 </select></td>
156 </tr>
157 </table>
158 END
159 ;
160 &Header::closebox();
161
162 print <<END
163 <div align='center'>
164 <table width='60%'>
165 <tr>
166 <td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
167 </tr>
168 </table>
169 </div>
170 END
171 ;
172
173 print "</form>\n";
174
175 &Header::closebigbox();
176
177 &Header::closepage();