]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/cgi-bin/logs.cgi/summary.dat
5 # This code is distributed under the terms of the GPL
7 # (c) The SmoothWall Team
9 # $Id: summary.dat,v 1.3.2.14 2005/07/10 00:48:42 franck78 Exp $
14 # enable only the following on debugging purpose
16 #use CGI::Carp 'fatalsToBrowser';
18 require '/var/ipfire/general-functions.pl';
19 require "${General::swroot}/lang.pl";
20 require "${General::swroot}/header.pl";
25 my $errormessage = '';
27 my @longmonths = ( $Lang::tr
{'january'}, $Lang::tr
{'february'}, $Lang::tr
{'march'},
28 $Lang::tr
{'april'}, $Lang::tr
{'may'}, $Lang::tr
{'june'}, $Lang::tr
{'july'}, $Lang::tr
{'august'},
29 $Lang::tr
{'september'}, $Lang::tr
{'october'}, $Lang::tr
{'november'},
30 $Lang::tr
{'december'} );
32 my @now = localtime();
33 my $year = $now[5]+1900;
35 $cgiparams{'MONTH'} = '';
36 $cgiparams{'DAY'} = '';
37 $cgiparams{'ACTION'} = '';
39 &Header
::getcgihash
(\
%cgiparams);
42 if ($ENV{'QUERY_STRING'} && $cgiparams{'ACTION'} ne $Lang::tr
{'update'}) {
43 my @temp = split(',',$ENV{'QUERY_STRING'});
45 $cgiparams{'MONTH'} = $temp[1];
46 $cgiparams{'DAY'} = $temp[2];
49 if (!($cgiparams{'MONTH'} =~ /^(0|1|2|3|4|5|6|7|8|9|10|11)$/) ||
50 !($cgiparams{'DAY'} =~ /^(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)$/)) {
51 # Reports are generated at the end of the day, so if nothing is selected
52 # we need to display yesterdays (todays won't have been generated yet)
54 my @temp_now = localtime(time);
55 $temp_now[4] = $now[4];
56 $temp_now[3] = $now[3];
57 @temp_then = localtime(POSIX
::mktime
(@temp_now) - 86400);
58 ## Retrieve the same time on the previous day -
59 ## 86400 seconds in a day
60 $cgiparams{'MONTH'} = $temp_then[4];
61 $cgiparams{'DAY'} = $temp_then[3];
63 elsif($cgiparams{'ACTION'} eq '>>') {
65 my @temp_now = localtime(time);
66 $temp_now[4] = $cgiparams{'MONTH'};
67 $temp_now[3] = $cgiparams{'DAY'};
68 @temp_then = localtime(POSIX
::mktime
(@temp_now) + 86400);
69 ## Retrieve the same time on the next day +
70 ## 86400 seconds in a day
71 $cgiparams{'MONTH'} = $temp_then[4];
72 $cgiparams{'DAY'} = $temp_then[3];
74 elsif($cgiparams{'ACTION'} eq '<<') {
76 my @temp_now = localtime(time);
77 $temp_now[4] = $cgiparams{'MONTH'};
78 $temp_now[3] = $cgiparams{'DAY'};
79 @temp_then = localtime(POSIX
::mktime
(@temp_now) - 86400);
80 ## Retrieve the same time on the previous day -
81 ## 86400 seconds in a day
82 $cgiparams{'MONTH'} = $temp_then[4];
83 $cgiparams{'DAY'} = $temp_then[3];
86 if (($cgiparams{'DAY'} ne $now[3]) || ($cgiparams{'MONTH'} ne $now[4])) {
87 if ( ($cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) ||
88 ($cgiparams{'MONTH'} > $now[4]) ) {
93 my $monthnum = $cgiparams{'MONTH'} + 1;
94 my $monthstr = $monthnum <= 9 ?
"0$monthnum" : "$monthnum";
95 my $longmonthstr = $longmonths[$cgiparams{'MONTH'}];
96 my $daystr = $cgiparams{'DAY'} <= 9 ?
"0$cgiparams{'DAY'}" : "$cgiparams{'DAY'}";
99 my $filestr="/var/log/logwatch/$year-$monthstr-$daystr";
101 if (!(open (FILE
,$filestr))) {
102 $errormessage = "$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}";
104 # Note: This is in case the log does not exist for that date
107 if (! $skip && $cgiparams{'ACTION'} eq $Lang::tr
{'export'}) {
108 print "Content-type: text/plain\n\n";
117 &Header
::showhttpheaders
();
119 &Header
::openpage
($Lang::tr
{'log summary'}, 1, '');
121 &Header
::openbigbox
('100%', 'left', '', $errormessage);
124 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
125 print "<font class='base'>$errormessage </font>\n";
129 &Header
::openbox
('100%', 'left', "$Lang::tr{'settings'}:");
132 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
135 <td width='10%' class='base'>$Lang::tr{'month'}:</td>
137 <select name='MONTH'>
140 for (my $month = 0; $month < 12; $month++)
143 if ($month == $cgiparams{'MONTH'}) {
144 print "selected='selected' "; }
145 print "value='$month'>$longmonths[$month]</option>\n";
150 <td width='10%' class='base'>$Lang::tr{'day'}:</td>
155 for (my $day = 1; $day <= 31; $day++)
158 if ($day == $cgiparams{'DAY'}) {
159 print "selected='selected' "; }
160 print "value='$day'>$day</option>\n";
165 <td width='5%' align='center'><input type='submit' name='ACTION' title='$Lang::tr{'day before'}' value='<<' /></td>
166 <td width='5%' align='center'><input type='submit' name='ACTION' title='$Lang::tr{'day after'}' value='>>' /></td>
167 <td width='10%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'update'}' /></td>
168 <td width='10%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'export'}' /></td>
183 if (/^\s*--+ ([^-]+) Begin --+\s*$/) {
184 # New Section. open box
186 &Header
::openbox
('100%', 'left', $Lang::tr
{"ls_\L$1"} ?
$Lang::tr
{"ls_\L$1"} : $1);
188 } elsif (/^\s*--+ ([^-]+) End --+\s*$/) {
189 # End of Section, kill leading and trailing blanks, print info, close
191 while ( $content[0] =~ /^\s*$/ ) { shift @content; }
192 while ( $content[$#content] =~ /^\s*$/ ) { pop @content; }
193 foreach $_ (@content) { $_ =~ s/\s*$//; print &Header
::cleanhtml
($_,"y")."\n"; }
196 } elsif (/^\s*#+ LogWatch [^#]+[)] #+\s*$/) {
197 # Start of logwatch header, skip it
199 } elsif (/^\s*#+\s*$/) {
200 # End of logwatch header
202 } elsif (/^\s*#+ LogWatch End #+\s*$/) {
204 } elsif ($header eq 0) {
211 &Header
::closebigbox
();
213 &Header
::closepage
();