#!/usr/bin/perl # # SmoothWall CGIs # # This code is distributed under the terms of the GPL # # (c) The SmoothWall Team # # $Id: summary.dat,v 1.3.2.4 2004/09/15 13:27:09 alanh Exp $ # require '/var/efw/header.pl'; use POSIX(); my %cgiparams; my @longmonths = ( $tr{'january'}, $tr{'february'}, $tr{'march'}, $tr{'april'}, $tr{'may'}, $tr{'june'}, $tr{'july'}, $tr{'august'}, $tr{'september'}, $tr{'october'}, $tr{'november'}, $tr{'december'} ); my @now = localtime(); my $year = $now[5]+1900; $cgiparams{'MONTH'} = ''; $cgiparams{'DAY'} = ''; $cgiparams{'ACTION'} = ''; &getcgihash(\%cgiparams); my $start = -1; if ($ENV{'QUERY_STRING'} && $cgiparams{'ACTION'} ne $tr{'update'}) { my @temp = split(',',$ENV{'QUERY_STRING'}); $start = $temp[0]; $cgiparams{'MONTH'} = $temp[1]; $cgiparams{'DAY'} = $temp[2]; } if (!($cgiparams{'MONTH'} =~ /^(0|1|2|3|4|5|6|7|8|9|10|11)$/) || !($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)$/)) { # Reports are generated at the end of the day, so if nothing is selected # we need to display yesterdays (todays won't have been generated yet) my @temp_then; my @temp_now = localtime(time); $temp_now[4] = $now[4]; $temp_now[3] = $now[3]; @temp_then = localtime(POSIX::mktime(@temp_now) - 86400); ## Retrieve the same time on the previous day - ## 86400 seconds in a day $cgiparams{'MONTH'} = $temp_then[4]; $cgiparams{'DAY'} = $temp_then[3]; } elsif($cgiparams{'ACTION'} eq '>>') { my @temp_then; my @temp_now = localtime(time); $temp_now[4] = $cgiparams{'MONTH'}; $temp_now[3] = $cgiparams{'DAY'}; @temp_then = localtime(POSIX::mktime(@temp_now) + 86400); ## Retrieve the same time on the next day - ## 86400 seconds in a day $cgiparams{'MONTH'} = $temp_then[4]; $cgiparams{'DAY'} = $temp_then[3]; } elsif($cgiparams{'ACTION'} eq '<<') { my @temp_then; my @temp_now = localtime(time); $temp_now[4] = $cgiparams{'MONTH'}; $temp_now[3] = $cgiparams{'DAY'}; @temp_then = localtime(POSIX::mktime(@temp_now) - 86400); ## Retrieve the same time on the previous day - ## 86400 seconds in a day $cgiparams{'MONTH'} = $temp_then[4]; $cgiparams{'DAY'} = $temp_then[3]; } if (($cgiparams{'DAY'} ne $now[3]) || ($cgiparams{'MONTH'} ne $now[4])) { if ( ($cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) || ($cgiparams{'MONTH'} > $now[4]) ) { $year = $year - 1; } } my $monthnum = $cgiparams{'MONTH'} + 1; my $monthstr; if ($monthnum <= 9) { $monthstr = "0$monthnum"; } else { $monthstr = $monthnum; } my $longmonthstr = $longmonths[$cgiparams{'MONTH'}]; my $day = $cgiparams{'DAY'}; my $daystr; if ($day <= 9) { $daystr = "0$day"; } else { $daystr = $day; } my $skip=0; my $filestr="/var/log/logwatch/$year-$monthstr-$daystr"; if (!(open (FILE,$filestr))) { $errormessage = "$tr{'date not in logs'}: $filestr $tr{'could not be opened'}"; $skip=1; # Note: This is in case the log does not exist for that date } my $lines = 0; my @log; if (!$skip) { while () { $log[$lines++] = $_; } close (FILE); if (!$lines) { $errormessage = "$tr{'date not in logs'}: $filestr"; $skip=1; } } if ($cgiparams{'ACTION'} eq $tr{'export'}) { print "Content-type: text/plain\n\n"; foreach $_ (@log) { print "$_\r\n"; } exit 0; } &showhttpheaders(); &openpage($tr{'log summary'}, 1, ''); &openbigbox('100%', 'left'); if ($errormessage) { &openbox('100%', 'left', $tr{'error messages'}); print "$errormessage \n"; &closebox(); } &openbox('100%', 'left', "$tr{'settings'}:"); print <
$tr{'month'} $tr{'day'}:
END ; &closebox(); my $header = 0; my @content; my $html_on = 0; if(!$skip) { if ($log[0] =~ m/\