From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Eitelwein To: development@lists.ipfire.org Subject: [PATCH 5/5] No code changes, fixed formatting by replacing spaces with tabs Date: Sun, 10 Jan 2016 18:42:52 +0100 Message-ID: <5692981C.5080007@eitelwein.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8178056924160052041==" List-Id: --===============8178056924160052041== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Signed-off-by: Michael Eitelwein --- html/cgi-bin/logs.cgi/firewalllog.dat | 494 ++++++++++----------- html/cgi-bin/logs.cgi/firewalllogcountry.dat | 531 +++++++++++---------= --- html/cgi-bin/logs.cgi/firewalllogip.dat | 432 +++++++++--------- html/cgi-bin/logs.cgi/firewalllogport.dat | 401 +++++++++-------- html/cgi-bin/logs.cgi/showrequestfromcountry.dat | 419 +++++++++--------- html/cgi-bin/logs.cgi/showrequestfromip.dat | 305 ++++++------- html/cgi-bin/logs.cgi/showrequestfromport.dat | 306 ++++++------- 7 files changed, 1459 insertions(+), 1429 deletions(-) diff --git a/html/cgi-bin/logs.cgi/firewalllog.dat b/html/cgi-bin/logs.cgi/fi= rewalllog.dat index df9b488..5c9722b 100644 --- a/html/cgi-bin/logs.cgi/firewalllog.dat +++ b/html/cgi-bin/logs.cgi/firewalllog.dat @@ -41,11 +41,11 @@ my %logsettings=3D(); my $errormessage =3D ''; my @shortmonths =3D ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug= ', - 'Sep', 'Oct', 'Nov', 'Dec' ); + 'Sep', 'Oct', 'Nov', 'Dec' ); my @longmonths =3D ( $Lang::tr{'january'}, $Lang::tr{'february'}, $Lang::tr= {'march'}, - $Lang::tr{'april'}, $Lang::tr{'may'}, $Lang::tr{'june'}, $Lang::tr{'= july'}, $Lang::tr{'august'}, - $Lang::tr{'september'}, $Lang::tr{'october'}, $Lang::tr{'november'}, - $Lang::tr{'december'} ); + $Lang::tr{'april'}, $Lang::tr{'may'}, $Lang::tr{'june'}, $Lang::tr{'july= '}, $Lang::tr{'august'}, + $Lang::tr{'september'}, $Lang::tr{'october'}, $Lang::tr{'november'}, + $Lang::tr{'december'} ); my @now =3D localtime(); my $dow =3D $now[6]; @@ -66,55 +66,55 @@ my $start =3D ($logsettings{'LOGVIEW_REVERSE'} eq 'on') ?= 0x7FFFF000 : 0; #index o if ($ENV{'QUERY_STRING'} && $cgiparams{'ACTION'} ne $Lang::tr{'update'}) { - my @temp =3D split(',',$ENV{'QUERY_STRING'}); - $start =3D $temp[0]; - $cgiparams{'MONTH'} =3D $temp[1]; - $cgiparams{'DAY'} =3D $temp[2]; + my @temp =3D split(',',$ENV{'QUERY_STRING'}); + $start =3D $temp[0]; + $cgiparams{'MONTH'} =3D $temp[1]; + $cgiparams{'DAY'} =3D $temp[2]; } if (!($cgiparams{'MONTH'} =3D~ /^(0|1|2|3|4|5|6|7|8|9|10|11)$/) || - !($cgiparams{'DAY'} =3D~ /^(0|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)$/)) + !($cgiparams{'DAY'} =3D~ /^(0|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)$/)) { - $cgiparams{'DAY'} =3D $now[3]; - $cgiparams{'MONTH'} =3D $now[4]; + $cgiparams{'DAY'} =3D $now[3]; + $cgiparams{'MONTH'} =3D $now[4]; } elsif($cgiparams{'ACTION'} eq '>>') { - my @temp_then=3D(); - my @temp_now =3D localtime(time); - $temp_now[4] =3D $cgiparams{'MONTH'}; - $temp_now[3] =3D $cgiparams{'DAY'}; - if ($cgiparams{'DAY'}) { - @temp_then =3D localtime(POSIX::mktime(@temp_now) + 86400); - ## Retrieve the same time on the next day + - ## 86400 seconds in a day - } else { - $temp_now[3] =3D 1; - $temp_now[4] =3D ($temp_now[4]+1) %12; - @temp_then =3D localtime(POSIX::mktime(@temp_now) ); - $temp_then[3] =3D 0; - } - $cgiparams{'MONTH'} =3D $temp_then[4]; - $cgiparams{'DAY'} =3D $temp_then[3]; + my @temp_then=3D(); + my @temp_now =3D localtime(time); + $temp_now[4] =3D $cgiparams{'MONTH'}; + $temp_now[3] =3D $cgiparams{'DAY'}; + if ($cgiparams{'DAY'}) { + @temp_then =3D localtime(POSIX::mktime(@temp_now) + 86400); + ## Retrieve the same time on the next day + + ## 86400 seconds in a day + } else { + $temp_now[3] =3D 1; + $temp_now[4] =3D ($temp_now[4]+1) %12; + @temp_then =3D localtime(POSIX::mktime(@temp_now) ); + $temp_then[3] =3D 0; + } + $cgiparams{'MONTH'} =3D $temp_then[4]; + $cgiparams{'DAY'} =3D $temp_then[3]; } elsif($cgiparams{'ACTION'} eq '<<') { - my @temp_then=3D(); - my @temp_now =3D localtime(time); - $temp_now[4] =3D $cgiparams{'MONTH'}; - $temp_now[3] =3D $cgiparams{'DAY'}; - if ($cgiparams{'DAY'}) { - @temp_then =3D localtime(POSIX::mktime(@temp_now) - 86400); - ## Retrieve the same time on the next day - - ## 86400 seconds in a day - } else { - $temp_now[3] =3D 1; - $temp_now[4] =3D ($temp_now[4]-1) %12; - @temp_then =3D localtime(POSIX::mktime(@temp_now) ); - $temp_then[3] =3D 0; - } - $cgiparams{'MONTH'} =3D $temp_then[4]; - $cgiparams{'DAY'} =3D $temp_then[3]; + my @temp_then=3D(); + my @temp_now =3D localtime(time); + $temp_now[4] =3D $cgiparams{'MONTH'}; + $temp_now[3] =3D $cgiparams{'DAY'}; + if ($cgiparams{'DAY'}) { + @temp_then =3D localtime(POSIX::mktime(@temp_now) - 86400); + ## Retrieve the same time on the next day - + ## 86400 seconds in a day + } else { + $temp_now[3] =3D 1; + $temp_now[4] =3D ($temp_now[4]-1) %12; + @temp_then =3D localtime(POSIX::mktime(@temp_now) ); + $temp_then[3] =3D 0; + } + $cgiparams{'MONTH'} =3D $temp_then[4]; + $cgiparams{'DAY'} =3D $temp_then[3]; } # Find in which file.gz is the log. Can be calculated because WEEKLY ROTATI= NG of access.log @@ -122,104 +122,104 @@ my $gzindex; my $date =3D $cgiparams{'DAY'} =3D=3D 0 ? '' : $cgiparams{'DAY'} <=3D 9 ? = "0$cgiparams{'DAY'}" : "$cgiparams{'DAY'}"; { - my $xday; - - # Calculate time. If future date, calculate for past year !!! - if (( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) || - ( $cgiparams{'MONTH'} > $now[4] ) ) { - $xday =3D POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MON= TH'}, $year - 1901 ); - $date =3D "$longmonths[$cgiparams{'MONTH'}] $date, ". int($year-1); - } else { - $xday =3D POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MON= TH'}, $year - 1900 ); - $date =3D "$longmonths[$cgiparams{'MONTH'}] $date, $year"; - } - - # calculate end of active week (saturday 23H59) - my @then =3D (); - @then =3D localtime(time()); - my $sunday =3D POSIX::mktime( 0, 0, 0, @then[3], @then[4], @then[5]); - $sunday +=3D (6-$then[6]) * 86400; - - # Convert delta in second to full weeks - $gzindex =3D int (($sunday-$xday)/604800 ); + my $xday; + + # Calculate time. If future date, calculate for past year !!! + if (( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) || + ( $cgiparams{'MONTH'} > $now[4] ) ) { + $xday =3D POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MON= TH'}, $year - 1901 ); + $date =3D "$longmonths[$cgiparams{'MONTH'}] $date, ". int($year-1); + } else { + $xday =3D POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MON= TH'}, $year - 1900 ); + $date =3D "$longmonths[$cgiparams{'MONTH'}] $date, $year"; + } + + # calculate end of active week (saturday 23H59) + my @then =3D (); + @then =3D localtime(time()); + my $sunday =3D POSIX::mktime( 0, 0, 0, @then[3], @then[4], @then[5]); + $sunday +=3D (6-$then[6]) * 86400; + + # Convert delta in second to full weeks + $gzindex =3D int (($sunday-$xday)/604800 ); } - + my $monthstr =3D $shortmonths[$cgiparams{'MONTH'}]; my $daystr =3D $cgiparams{'DAY'} =3D=3D 0 ? '..' : $cgiparams{'DAY'} <=3D= 9 ? " $cgiparams{'DAY'}" : "$cgiparams{'DAY'}"; - + my $lines =3D 0; my @log=3D(); my $loop =3D 1; my $filestr =3D 0; -my $lastdatetime; # for debug +my $lastdatetime; # for debug my $search_for_end =3D 0; - + while ($gzindex >=3D0 && $loop) { - # calculate file name - if ($gzindex =3D=3D 0) { - $filestr =3D "/var/log/messages"; - } else { - $filestr =3D "/var/log/messages.$gzindex"; - $filestr =3D "$filestr.gz" if -f "$filestr.gz"; - } - # now read file if existing - if (open (FILE,($filestr =3D~ /.gz$/ ? "gzip -dc $filestr |" : $file= str))) { - #&General::log("reading $filestr"); - READ:while () { - my $line =3D $_; - if ($line =3D~ /^${monthstr} ${daystr} ..:..:.. [\w\-]+ kern= el:.*IN=3D.*$/) { - # when standart viewing, just keep in memory the correct= slice - # it starts a '$start' and size is $viewport - # If export, then keep all lines... - if ($cgiparams{'ACTION'} eq $Lang::tr{'export'}){ - $log[$lines++] =3D "$line"; - } else { - if ($lines++ < ($start + $Header::viewsize)) { - push(@log,"$line"); - if (@log > $Header::viewsize) { - shift (@log); - } - #} else { dont do this optimisation, need to count l= ines ! - # $datetime =3D $maxtime; # we have read view= size lines, stop main loop - # last READ; # exit read file - } - } - $search_for_end =3D 1; # we find the start of sli= ce, can look for end now - } else { - if ($search_for_end =3D=3D 1) { - #finish read files when date is over (test month equ= ality only) - $line =3D~ /^(...) (..) ..:..:..*$/; - $loop =3D 0 if ( ($1 ne $monthstr) || ( ($daystr ne = '..') && ($daystr ne $2) ) ); - } - } - } - close (FILE); - } - $gzindex--; # will try next gz file eg 40,39,38,.... because it = may have holes when ipcop stopped - # for a long time + # calculate file name + if ($gzindex =3D=3D 0) { + $filestr =3D "/var/log/messages"; + } else { + $filestr =3D "/var/log/messages.$gzindex"; + $filestr =3D "$filestr.gz" if -f "$filestr.gz"; + } + # now read file if existing + if (open (FILE,($filestr =3D~ /.gz$/ ? "gzip -dc $filestr |" : $filestr)= )) { + #&General::log("reading $filestr"); + READ:while () { + my $line =3D $_; + if ($line =3D~ /^${monthstr} ${daystr} ..:..:.. [\w\-]+ kernel:.= *IN=3D.*$/) { + # when standart viewing, just keep in memory the correct sli= ce + # it starts a '$start' and size is $viewport + # If export, then keep all lines... + if ($cgiparams{'ACTION'} eq $Lang::tr{'export'}){ + $log[$lines++] =3D "$line"; + } else { + if ($lines++ < ($start + $Header::viewsize)) { + push(@log,"$line"); + if (@log > $Header::viewsize) { + shift (@log); + } + #} else { dont do this optimisation, need to count lines= ! + # $datetime =3D $maxtime; # we have read viewsize lin= es, stop main loop + # last READ; # exit read file + } + } + $search_for_end =3D 1; # we find the start of slice, can = look for end now + } else { + if ($search_for_end =3D=3D 1) { + #finish read files when date is over (test month equalit= y only) + $line =3D~ /^(...) (..) ..:..:..*$/; + $loop =3D 0 if ( ($1 ne $monthstr) || ( ($daystr ne '..'= ) && ($daystr ne $2) ) ); + } + } + } + close (FILE); + } + $gzindex--; # will try next gz file eg 40,39,38,.... because it may = have holes when ipcop stopped + # for a long time }# while # $errormessage =3D "$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'co= uld not be opened'}"; if ($cgiparams{'ACTION'} eq $Lang::tr{'export'}) { - print "Content-type: text/plain\n\n"; - print "IPFire firewall log\r\n"; - print "$Lang::{'date'}: $date\r\n\r\n"; - - if ($logsettings{'LOGVIEW_REVERSE'} eq 'on') { @log =3D reverse @log= ; } - - foreach $_ (@log) - { - /^... (..) (..:..:..) [\w\-]+ kernel:.*(IN=3D.*)$/; - my $day =3D $1; - $day =3D~ tr / /0/; - my $time =3D $cgiparams{'DAY'} ? "$2" : "$day/$2" ; - print "$time $3\r\n"; - - } - exit 0; + print "Content-type: text/plain\n\n"; + print "IPFire firewall log\r\n"; + print "$Lang::{'date'}: $date\r\n\r\n"; + + if ($logsettings{'LOGVIEW_REVERSE'} eq 'on') { @log =3D reverse @log; } + + foreach $_ (@log) + { + /^... (..) (..:..:..) [\w\-]+ kernel:.*(IN=3D.*)$/; + my $day =3D $1; + $day =3D~ tr / /0/; + my $time =3D $cgiparams{'DAY'} ? "$2" : "$day/$2" ; + print "$time $3\r\n"; + + } + exit 0; } &Header::showhttpheaders(); @@ -229,9 +229,9 @@ if ($cgiparams{'ACTION'} eq $Lang::tr{'export'}) &Header::openbigbox('100%', 'left', '', $errormessage); if ($errormessage) { - &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); - print "$errormessage \n"; - &Header::closebox(); + &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); + print "$errormessage \n"; + &Header::closebox(); } &Header::openbox('100%', 'left', "$Lang::tr{'settings'}"); @@ -240,33 +240,35 @@ print < - - + - - + + - - - - + + + + + + + + END ; @@ -330,70 +332,74 @@ foreach $_ (@log) { # If ipv6 uses a bridge, PHYSIN=3D contains the relevant iface informat= ion # otherwise use IN=3D - my $packet =3D ''; - if ($_ =3D~ /^... (..) (..:..:..) [\w\-]+ kernel:(.*)(IN=3D.*)(PHYSI= N=3D.*)$/) { $packet =3D $5; } - elsif ($_ =3D~ /^... (..) (..:..:..) [\w\-]+ kernel:(.*)(IN=3D.*)$/)= { $packet =3D $4; } - my $day =3D $1; - $day =3D~ tr / /0/; - my $time =3D $cgiparams{'DAY'} ? "$2" : "$day/$2" ; - my $chain =3D $3; - - my ($iface, $srcaddr, $dstaddr, $macaddr, $proto, $srcport, $dstport= ); - if ($packet =3D~ /PHYSIN=3D(\w+)/) { $iface=3D$1; } elsif ($packet = =3D~ /IN=3D(\w+)/) { $iface =3D $1; } - # Identify whether ipv4 or ipv6. Both are mutally exclusive. - if ($packet =3D~ /SRC\=3D(([\d]{1,3})(\.([\d]{1,3})){3})/) { $srcadd= r=3D$1; } - if ($packet =3D~ /SRC\=3D(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{= 0,4})){2,7})/) { $srcaddr=3D$1; } - if ($packet =3D~ /DST\=3D(([\d]{1,3})(\.([\d]{1,3})){3})/) { $dstadd= r=3D$1; } - if ($packet =3D~ /DST\=3D(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{= 0,4})){2,7})/) { $dstaddr=3D$1; } - $macaddr=3D$1 if $packet =3D~ /MAC=3D([\w+\:]+)/; - $proto=3D$1 if $packet =3D~ /PROTO=3D(\w+)/; - $srcport=3D$1 if $packet =3D~ /SPT=3D(\d+)/; - $dstport=3D$1 if $packet =3D~ /DPT=3D(\d+)/; - - my $gi =3D Geo::IP::PurePerl->new(); - my $ccode =3D $gi->country_code_by_name($srcaddr); - my $fcode =3D lc($ccode); - - my $servi =3D uc(getservbyport($srcport, lc($proto))); - if ($servi ne '' && $srcport < 1024) { - $srcport =3D "$srcport($servi)"; } - $servi =3D uc(getservbyport($dstport, lc($proto))); - if ($servi ne '' && $dstport < 1024) { - $dstport =3D "$dstport($servi)";} - my @mactemp =3D split(/:/,$macaddr); - $macaddr =3D "$mactemp[6]:$mactemp[7]:$mactemp[8]:$mactemp[9]:$macte= mp[10]:$mactemp[11]"; - my $col=3D""; - if ($lines % 2) { - print ""; - $col=3D"bgcolor=3D'$color{'color20'}'"; } - else { - print ""; - $col=3D"bgcolor=3D'$color{'color22'}'"; } - print <$time - - - - - + my $packet =3D ''; + if ($_ =3D~ /^... (..) (..:..:..) [\w\-]+ kernel:(.*)(IN=3D.*)(PHYSIN=3D= .*)$/) { $packet =3D $5; } + elsif ($_ =3D~ /^... (..) (..:..:..) [\w\-]+ kernel:(.*)(IN=3D.*)$/) { $= packet =3D $4; } + my $day =3D $1; + $day =3D~ tr / /0/; + my $time =3D $cgiparams{'DAY'} ? "$2" : "$day/$2" ; + my $chain =3D $3; + + my ($iface, $srcaddr, $dstaddr, $macaddr, $proto, $srcport, $dstport); + if ($packet =3D~ /PHYSIN=3D(\w+)/) { $iface=3D$1; } elsif ($packet =3D~ = /IN=3D(\w+)/) { $iface =3D $1; } + # Identify whether ipv4 or ipv6. Both are mutally exclusive. + if ($packet =3D~ /SRC\=3D(([\d]{1,3})(\.([\d]{1,3})){3})/) { $srcaddr=3D= $1; } + if ($packet =3D~ /SRC\=3D(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})= /) { $srcaddr=3D$1; } + if ($packet =3D~ /DST\=3D(([\d]{1,3})(\.([\d]{1,3})){3})/) { $dstaddr=3D= $1; } + if ($packet =3D~ /DST\=3D(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})= /) { $dstaddr=3D$1; } + $macaddr=3D$1 if $packet =3D~ /MAC=3D([\w+\:]+)/; + $proto=3D$1 if $packet =3D~ /PROTO=3D(\w+)/; + $srcport=3D$1 if $packet =3D~ /SPT=3D(\d+)/; + $dstport=3D$1 if $packet =3D~ /DPT=3D(\d+)/; + + my $gi =3D Geo::IP::PurePerl->new(); + my $ccode =3D $gi->country_code_by_name($srcaddr); + my $fcode =3D lc($ccode); + + my $servi =3D uc(getservbyport($srcport, lc($proto))); + if ($servi ne '' && $srcport < 1024) { + $srcport =3D "$srcport($servi)"; + } + $servi =3D uc(getservbyport($dstport, lc($proto))); + if ($servi ne '' && $dstport < 1024) { + $dstport =3D "$dstport($servi)"; + } + my @mactemp =3D split(/:/,$macaddr); + $macaddr =3D "$mactemp[6]:$mactemp[7]:$mactemp[8]:$mactemp[9]:$mactemp[1= 0]:$mactemp[11]"; + my $col=3D""; + if ($lines % 2) { + print ""; + $col=3D"bgcolor=3D'$color{'color20'}'"; + } + else { + print ""; + $col=3D"bgcolor=3D'$color{'color22'}'"; + } + print <$time + + + + END -; + ; # Get flag icon for of the country. my $flag_icon =3D &GeoIP::get_flag_icon($fcode); - if ( $flag_icon) { + if ( $flag_icon) { print ""; } - print <$macaddr - + print <$macaddr + END - ; - $lines++; + ; + $lines++; } print "
$Lang::tr{'month'}:  - $Lang::tr{'month'}:  +  $Lang::tr{'da= y'}:  - +  $Lang::tr{'day'}:=   +
$Lang::tr{'time'}$Lang::tr{'chain'} - $Lang::tr{'iface'} - $Lang::tr{'proto'} - $Lang::tr{'source'}
$= Lang::tr{'destination'}
$Lang::tr{'src port'}
$Lang::tr{'dst port'}
$Lang::tr{'country'}<= /th> - $Lang::tr{'mac address'}<= /b>$Lang::tr{'time'}$Lang::tr{'chain'}$Lang::tr{'iface'}$Lang::tr{'proto'}$Lang::tr{'source'}
$Lang= ::tr{'destination'}
$Lang::tr{'src port'}
$L= ang::tr{'dst port'}
$Lang::tr{'country'}$Lang::tr{'mac address'}<= /th>
$chain$iface$proto$srcaddr
$dstaddr<= /a>
$srcport
$dstport
$chain$iface$proto= $srcaddr
$dstaddr<= /td> +
$srcport
$dstport
= 3D'$ccode'<= /td>"; } else { print "
"; @@ -408,32 +414,36 @@ print ""; sub oldernewer { -print < - + print < + END -; + ; -print ""; -if ($prev !=3D -1) { - print "$Lang::tr{'first'} "; - print "$Lang::tr{'older'}"; } -else { - print "$Lang::tr{'first'} $Lang::tr{'older'}"; } -print "\n"; - -print ""; -if ($next >=3D 0) { - print "$Lang::tr{'newer'} "; - print "$Lang::tr{'last'}"; } -else { - print "$Lang::tr{'newer'} $Lang::tr{'last'} "; } -print "\n"; + print ""; + if ($prev !=3D -1) { + print "$Lang::tr{'first'} "; + print "$Lang::tr{'older'}"; + } + else { + print "$Lang::tr{'first'} $Lang::tr{'older'}"; + } + print "\n"; -print < - + print ""; + if ($next >=3D 0) { + print "$Lang::tr{'newer'} "; + print "$Lang::tr{'last'}"; + } + else { + print "$Lang::tr{'newer'} $Lang::tr{'last'} "; + } + print "\n"; + + print < + END -; + ; } diff --git a/html/cgi-bin/logs.cgi/firewalllogcountry.dat b/html/cgi-bin/logs= .cgi/firewalllogcountry.dat index 087b844..26920b5 100644 --- a/html/cgi-bin/logs.cgi/firewalllogcountry.dat +++ b/html/cgi-bin/logs.cgi/firewalllogcountry.dat @@ -8,7 +8,7 @@ # page inspired from the initial firewalllog.dat # # Modified for IPFire by Christian Schmidt -# and Michael Tremer (www.ipfire.org) +# and Michael Tremer (www.ipfire.org) use strict; use Geo::IP::PurePerl; @@ -39,11 +39,11 @@ $cgiparams{'showpie'} =3D 1; $cgiparams{'sortcolumn'} =3D 1; my @shortmonths =3D ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug= ', - 'Sep', 'Oct', 'Nov', 'Dec' ); + 'Sep', 'Oct', 'Nov', 'Dec' ); my @longmonths =3D ( $Lang::tr{'january'}, $Lang::tr{'february'}, $Lang::tr= {'march'}, - $Lang::tr{'april'}, $Lang::tr{'may'}, $Lang::tr{'june'}, $Lang::tr{'= july'}, $Lang::tr{'august'}, - $Lang::tr{'september'}, $Lang::tr{'october'}, $Lang::tr{'november'}, - $Lang::tr{'december'} ); + $Lang::tr{'april'}, $Lang::tr{'may'}, $Lang::tr{'june'}, $Lang::tr{'july= '}, $Lang::tr{'august'}, + $Lang::tr{'september'}, $Lang::tr{'october'}, $Lang::tr{'november'}, + $Lang::tr{'december'} ); my @now =3D localtime(); my $dow =3D $now[6]; @@ -69,81 +69,81 @@ if ($cgiparams{'sortcolumn'} !=3D 0) { $settings{'sortcol= umn'} =3D $cgiparams{'sortc if ($cgiparams{'ACTION'} eq $Lang::tr{'save'}) { - &General::writehash("${General::swroot}/fwlogs/ipsettings", \%settings); + &General::writehash("${General::swroot}/fwlogs/ipsettings", \%settings); } my $start =3D -1; if ($ENV{'QUERY_STRING'} && $cgiparams{'ACTION'} ne $Lang::tr{'update'}) { - my @temp =3D split(',',$ENV{'QUERY_STRING'}); - $start =3D $temp[0]; - $cgiparams{'MONTH'} =3D $temp[1]; - $cgiparams{'DAY'} =3D $temp[2]; + my @temp =3D split(',',$ENV{'QUERY_STRING'}); + $start =3D $temp[0]; + $cgiparams{'MONTH'} =3D $temp[1]; + $cgiparams{'DAY'} =3D $temp[2]; } if (!($cgiparams{'MONTH'} =3D~ /^(0|1|2|3|4|5|6|7|8|9|10|11)$/) || !($cgiparams{'DAY'} =3D~ /^(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|1= 8|19|20|21|22|23|24|25|26|27|28|29|30|31)$/)) { - $cgiparams{'DAY'} =3D $now[3]; - $cgiparams{'MONTH'} =3D $now[4]; + $cgiparams{'DAY'} =3D $now[3]; + $cgiparams{'MONTH'} =3D $now[4]; } elsif($cgiparams{'ACTION'} eq '>>') { - my @temp_then=3D(); - my @temp_now =3D localtime(time); - $temp_now[4] =3D $cgiparams{'MONTH'}; - $temp_now[3] =3D $cgiparams{'DAY'}; - @temp_then =3D localtime(POSIX::mktime(@temp_now) + 86400); - ## Retrieve the same time on the next day - - ## 86400 seconds in a day - $cgiparams{'MONTH'} =3D $temp_then[4]; - $cgiparams{'DAY'} =3D $temp_then[3]; + my @temp_then=3D(); + my @temp_now =3D localtime(time); + $temp_now[4] =3D $cgiparams{'MONTH'}; + $temp_now[3] =3D $cgiparams{'DAY'}; + @temp_then =3D localtime(POSIX::mktime(@temp_now) + 86400); + ## Retrieve the same time on the next day - + ## 86400 seconds in a day + $cgiparams{'MONTH'} =3D $temp_then[4]; + $cgiparams{'DAY'} =3D $temp_then[3]; } elsif($cgiparams{'ACTION'} eq '<<') { - my @temp_then=3D(); - my @temp_now =3D localtime(time); - $temp_now[4] =3D $cgiparams{'MONTH'}; - $temp_now[3] =3D $cgiparams{'DAY'}; - @temp_then =3D localtime(POSIX::mktime(@temp_now) - 86400); - ## Retrieve the same time on the previous day - - ## 86400 seconds in a day - $cgiparams{'MONTH'} =3D $temp_then[4]; - $cgiparams{'DAY'} =3D $temp_then[3]; + my @temp_then=3D(); + my @temp_now =3D localtime(time); + $temp_now[4] =3D $cgiparams{'MONTH'}; + $temp_now[3] =3D $cgiparams{'DAY'}; + @temp_then =3D localtime(POSIX::mktime(@temp_now) - 86400); + ## Retrieve the same time on the previous day - + ## 86400 seconds in a day + $cgiparams{'MONTH'} =3D $temp_then[4]; + $cgiparams{'DAY'} =3D $temp_then[3]; } if (($cgiparams{'DAY'} ne $now[3]) || ($cgiparams{'MONTH'} ne $now[4])) { - my @then =3D (); - if ( ( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now= [3]) || - ( $cgiparams{'MONTH'} > $now[4] ) ) { - @then =3D localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'= }, $cgiparams{'MONTH'}, $year - 1901 )); - } else { - @then =3D localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'= }, $cgiparams{'MONTH'}, $year - 1900 )); - } - $tdoy =3D $then[7]; - my $lastleap=3D($year-1)%4; - if ($tdoy>$doy) { - if ($lastleap =3D=3D 0 && $tdoy < 60) { - $doy=3D$tdoy+366; - } else { - $doy=3D$doy+365; - } - } + my @then =3D (); + if ( ( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3])= || + ( $cgiparams{'MONTH'} > $now[4] ) ) { + @then =3D localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgip= arams{'MONTH'}, $year - 1901 )); + } else { + @then =3D localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgip= arams{'MONTH'}, $year - 1900 )); + } + $tdoy =3D $then[7]; + my $lastleap=3D($year-1)%4; + if ($tdoy>$doy) { + if ($lastleap =3D=3D 0 && $tdoy < 60) { + $doy=3D$tdoy+366; + } else { + $doy=3D$doy+365; + } + } } my $datediff=3D0; my $dowd=3D0; my $multifile=3D0; if ($tdoy ne $doy) { - $datediff=3Dint(($doy-$tdoy)/7); - $dowd=3D($doy-$tdoy)%7; - if (($dow-$dowd)<1) { - $datediff=3D$datediff+1; - } - if (($dow-$dowd)=3D=3D0) { - $multifile=3D1; - } + $datediff=3Dint(($doy-$tdoy)/7); + $dowd=3D($doy-$tdoy)%7; + if (($dow-$dowd)<1) { + $datediff=3D$datediff+1; + } + if (($dow-$dowd)=3D=3D0) { + $multifile=3D1; + } } my $monthstr =3D $shortmonths[$cgiparams{'MONTH'}]; @@ -151,62 +151,63 @@ my $longmonthstr =3D $longmonths[$cgiparams{'MONTH'}]; my $day =3D $cgiparams{'DAY'}; my $daystr=3D''; if ($day <=3D 9) { - $daystr =3D " $day"; } + $daystr =3D " $day"; +} else { - $daystr =3D $day; + $daystr =3D $day; } my $skip=3D0; my $filestr=3D''; if ($datediff=3D=3D0) { - $filestr=3D"/var/log/messages"; + $filestr=3D"/var/log/messages"; } else { - $filestr=3D"/var/log/messages.$datediff"; - $filestr =3D "$filestr.gz" if -f "$filestr.gz"; + $filestr=3D"/var/log/messages.$datediff"; + $filestr =3D "$filestr.gz" if -f "$filestr.gz"; } if (!(open (FILE,($filestr =3D~ /.gz$/ ? "gzip -dc $filestr |" : $filestr))= )) { - $errormessage =3D "$Lang::tr{'date not in logs'}: $filestr $Lang::tr= {'could not be opened'}"; - $skip=3D1; - # Note: This is in case the log does not exist for that date + $errormessage =3D "$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'co= uld not be opened'}"; + $skip=3D1; + # Note: This is in case the log does not exist for that date } my $lines =3D 0; my @log=3D(); if (!$skip) { - while () - { - if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN= =3D.*)$/) { - $log[$lines] =3D $_; - $lines++; - } - } - close (FILE); + while () + { + if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=3D.*)$/)= { + $log[$lines] =3D $_; + $lines++; + } + } + close (FILE); } $skip=3D0; if ($multifile) { - $datediff=3D$datediff-1; - if ($datediff=3D=3D0) { - $filestr=3D"/var/log/messages"; - } else { - $filestr=3D"/var/log/messages.$datediff"; - $filestr =3D "$filestr.gz" if -f "$filestr.gz"; - } - if (!(open (FILE,($filestr =3D~ /.gz$/ ? "gzip -dc $filestr |" : $fi= lestr)))) { - $errormessage=3D"$Lang::tr{'date not in logs'}: $filestr $La= ng::tr{'could not be opened'}"; - $skip=3D1; - } - if (!$skip) { - while () { - if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kerne= l:.*(IN=3D.*)$/) { - $log[$lines] =3D $_; - $lines++; - } - } - close (FILE); - } + $datediff=3D$datediff-1; + if ($datediff=3D=3D0) { + $filestr=3D"/var/log/messages"; + } else { + $filestr=3D"/var/log/messages.$datediff"; + $filestr =3D "$filestr.gz" if -f "$filestr.gz"; + } + if (!(open (FILE,($filestr =3D~ /.gz$/ ? "gzip -dc $filestr |" : $filest= r)))) { + $errormessage=3D"$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'= could not be opened'}"; + $skip=3D1; + } + if (!$skip) { + while () { + if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=3D.*= )$/) { + $log[$lines] =3D $_; + $lines++; + } + } + close (FILE); + } } my $MODNAME=3D"fwlogs"; @@ -217,9 +218,9 @@ my $MODNAME=3D"fwlogs"; if ($errormessage) { - &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); - print "$errormessage \n"; - &Header::closebox(); + &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); + print "$errormessage \n"; + &Header::closebox(); } &Header::openbox('100%', 'left', "$Lang::tr{'settings'}"); @@ -228,33 +229,33 @@ print < - - + - - + + "; - - print ""; - } - else { - my $fcode =3D lc($key[$s]); - - # Get flag icon for of the country. - my $flag_icon =3D &GeoIP::get_flag_icon($fcode); - - if($flag_icon) { - print ""; - } else { + $show++; + $percent =3D $value[$s] * 100 / $linesjc; + $percent =3D sprintf("%.f", $percent); + $total =3D $total + $value[$s]; + # colors are numbered 1 to 10 + my $colorIndex =3D ($color % 10) + 1; + $col=3D"bgcolor=3D'$color{\"color$colorIndex\"}'"; + $color++; + print ""; + + print ""; - } - } - print ""; - print ""; - print ""; + } + else { + my $fcode =3D lc($key[$s]); + + # Get flag icon for of the country. + my $flag_icon =3D &GeoIP::get_flag_icon($fcode); + + if($flag_icon) { + print ""; + } else { + print ""; + } + } + print ""; + print ""; + print ""; } if($cgiparams{'otherspie'} =3D=3D 2 ){} else{ - # colors are numbered 1 to 10 - my $colorIndex =3D ($color % 10) + 1; - $col=3D"bgcolor=3D'$color{\"color$colorIndex\"}'"; - print ""; - -if ( $linesjc ne "0") -{ -my $dif; -$dif =3D $linesjc - $total; -$percent =3D $dif * 100 / $linesjc; -$percent =3D sprintf("%.f", $percent); -print < - - - - + # colors are numbered 1 to 10 + my $colorIndex =3D ($color % 10) + 1; + $col=3D"bgcolor=3D'$color{\"color$colorIndex\"}'"; + print ""; + + if ( $linesjc ne "0") + { + my $dif; + $dif =3D $linesjc - $total; + $percent =3D $dif * 100 / $linesjc; + $percent =3D sprintf("%.f", $percent); + print < + + + + END -; -} + ; + } } print < @@ -533,19 +530,19 @@ END &Header::closepage(); sub findkey { - my $v; - foreach $v (@keytabjc) { - if ($tabjc{$v} eq $_[0]) { - delete $tabjc{$v}; - $key[$indice] =3D "$v"; - $value[$indice] =3D $_[0]; - $indice++; - last; - } - } + my $v; + foreach $v (@keytabjc) { + if ($tabjc{$v} eq $_[0]) { + delete $tabjc{$v}; + $key[$indice] =3D "$v"; + $value[$indice] =3D $_[0]; + $indice++; + last; + } + } } sub checkversion { - #Automatic Updates is disabled - return "0","0"; + #Automatic Updates is disabled + return "0","0"; } diff --git a/html/cgi-bin/logs.cgi/firewalllogip.dat b/html/cgi-bin/logs.cgi/= firewalllogip.dat index 6fc3422..08ef1c4 100644 --- a/html/cgi-bin/logs.cgi/firewalllogip.dat +++ b/html/cgi-bin/logs.cgi/firewalllogip.dat @@ -8,7 +8,7 @@ # page inspired from the initial firewalllog.dat # # Modified for IPFire by Christian Schmidt -# and Michael Tremer (www.ipfire.org) +# and Michael Tremer (www.ipfire.org) use strict; use Geo::IP::PurePerl; @@ -39,11 +39,11 @@ $cgiparams{'showpie'} =3D 1; $cgiparams{'sortcolumn'} =3D 1; my @shortmonths =3D ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug= ', - 'Sep', 'Oct', 'Nov', 'Dec' ); + 'Sep', 'Oct', 'Nov', 'Dec' ); my @longmonths =3D ( $Lang::tr{'january'}, $Lang::tr{'february'}, $Lang::tr= {'march'}, - $Lang::tr{'april'}, $Lang::tr{'may'}, $Lang::tr{'june'}, $Lang::tr{'= july'}, $Lang::tr{'august'}, - $Lang::tr{'september'}, $Lang::tr{'october'}, $Lang::tr{'november'}, - $Lang::tr{'december'} ); + $Lang::tr{'april'}, $Lang::tr{'may'}, $Lang::tr{'june'}, $Lang::tr{'july= '}, $Lang::tr{'august'}, + $Lang::tr{'september'}, $Lang::tr{'october'}, $Lang::tr{'november'}, + $Lang::tr{'december'} ); my @now =3D localtime(); my $dow =3D $now[6]; @@ -69,81 +69,81 @@ if ($cgiparams{'sortcolumn'} !=3D 0) { $settings{'sortcol= umn'} =3D $cgiparams{'sortc if ($cgiparams{'ACTION'} eq $Lang::tr{'save'}) { - &General::writehash("${General::swroot}/fwlogs/ipsettings", \%settings); + &General::writehash("${General::swroot}/fwlogs/ipsettings", \%settings); } my $start =3D -1; if ($ENV{'QUERY_STRING'} && $cgiparams{'ACTION'} ne $Lang::tr{'update'}) { - my @temp =3D split(',',$ENV{'QUERY_STRING'}); - $start =3D $temp[0]; - $cgiparams{'MONTH'} =3D $temp[1]; - $cgiparams{'DAY'} =3D $temp[2]; + my @temp =3D split(',',$ENV{'QUERY_STRING'}); + $start =3D $temp[0]; + $cgiparams{'MONTH'} =3D $temp[1]; + $cgiparams{'DAY'} =3D $temp[2]; } if (!($cgiparams{'MONTH'} =3D~ /^(0|1|2|3|4|5|6|7|8|9|10|11)$/) || !($cgiparams{'DAY'} =3D~ /^(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|1= 8|19|20|21|22|23|24|25|26|27|28|29|30|31)$/)) { - $cgiparams{'DAY'} =3D $now[3]; - $cgiparams{'MONTH'} =3D $now[4]; + $cgiparams{'DAY'} =3D $now[3]; + $cgiparams{'MONTH'} =3D $now[4]; } elsif($cgiparams{'ACTION'} eq '>>') { - my @temp_then=3D(); - my @temp_now =3D localtime(time); - $temp_now[4] =3D $cgiparams{'MONTH'}; - $temp_now[3] =3D $cgiparams{'DAY'}; - @temp_then =3D localtime(POSIX::mktime(@temp_now) + 86400); - ## Retrieve the same time on the next day - - ## 86400 seconds in a day - $cgiparams{'MONTH'} =3D $temp_then[4]; - $cgiparams{'DAY'} =3D $temp_then[3]; + my @temp_then=3D(); + my @temp_now =3D localtime(time); + $temp_now[4] =3D $cgiparams{'MONTH'}; + $temp_now[3] =3D $cgiparams{'DAY'}; + @temp_then =3D localtime(POSIX::mktime(@temp_now) + 86400); + ## Retrieve the same time on the next day - + ## 86400 seconds in a day + $cgiparams{'MONTH'} =3D $temp_then[4]; + $cgiparams{'DAY'} =3D $temp_then[3]; } elsif($cgiparams{'ACTION'} eq '<<') { - my @temp_then=3D(); - my @temp_now =3D localtime(time); - $temp_now[4] =3D $cgiparams{'MONTH'}; - $temp_now[3] =3D $cgiparams{'DAY'}; - @temp_then =3D localtime(POSIX::mktime(@temp_now) - 86400); - ## Retrieve the same time on the previous day - - ## 86400 seconds in a day - $cgiparams{'MONTH'} =3D $temp_then[4]; - $cgiparams{'DAY'} =3D $temp_then[3]; + my @temp_then=3D(); + my @temp_now =3D localtime(time); + $temp_now[4] =3D $cgiparams{'MONTH'}; + $temp_now[3] =3D $cgiparams{'DAY'}; + @temp_then =3D localtime(POSIX::mktime(@temp_now) - 86400); + ## Retrieve the same time on the previous day - + ## 86400 seconds in a day + $cgiparams{'MONTH'} =3D $temp_then[4]; + $cgiparams{'DAY'} =3D $temp_then[3]; } if (($cgiparams{'DAY'} ne $now[3]) || ($cgiparams{'MONTH'} ne $now[4])) { - my @then =3D (); - if ( ( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now= [3]) || - ( $cgiparams{'MONTH'} > $now[4] ) ) { - @then =3D localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'= }, $cgiparams{'MONTH'}, $year - 1901 )); - } else { - @then =3D localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'= }, $cgiparams{'MONTH'}, $year - 1900 )); - } - $tdoy =3D $then[7]; - my $lastleap=3D($year-1)%4; - if ($tdoy>$doy) { - if ($lastleap =3D=3D 0 && $tdoy < 60) { - $doy=3D$tdoy+366; - } else { - $doy=3D$doy+365; - } - } + my @then =3D (); + if ( ( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3])= || + ( $cgiparams{'MONTH'} > $now[4] ) ) { + @then =3D localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgip= arams{'MONTH'}, $year - 1901 )); + } else { + @then =3D localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgip= arams{'MONTH'}, $year - 1900 )); + } + $tdoy =3D $then[7]; + my $lastleap=3D($year-1)%4; + if ($tdoy>$doy) { + if ($lastleap =3D=3D 0 && $tdoy < 60) { + $doy=3D$tdoy+366; + } else { + $doy=3D$doy+365; + } + } } my $datediff=3D0; my $dowd=3D0; my $multifile=3D0; if ($tdoy ne $doy) { - $datediff=3Dint(($doy-$tdoy)/7); - $dowd=3D($doy-$tdoy)%7; - if (($dow-$dowd)<1) { - $datediff=3D$datediff+1; - } - if (($dow-$dowd)=3D=3D0) { - $multifile=3D1; - } + $datediff=3Dint(($doy-$tdoy)/7); + $dowd=3D($doy-$tdoy)%7; + if (($dow-$dowd)<1) { + $datediff=3D$datediff+1; + } + if (($dow-$dowd)=3D=3D0) { + $multifile=3D1; + } } my $monthstr =3D $shortmonths[$cgiparams{'MONTH'}]; @@ -151,62 +151,62 @@ my $longmonthstr =3D $longmonths[$cgiparams{'MONTH'}]; my $day =3D $cgiparams{'DAY'}; my $daystr=3D''; if ($day <=3D 9) { - $daystr =3D " $day"; } + $daystr =3D " $day"; } else { - $daystr =3D $day; + $daystr =3D $day; } my $skip=3D0; my $filestr=3D''; if ($datediff=3D=3D0) { - $filestr=3D"/var/log/messages"; + $filestr=3D"/var/log/messages"; } else { $filestr=3D"/var/log/messages.$datediff"; $filestr =3D "$filestr.gz" if -f "$filestr.gz"; } if (!(open (FILE,($filestr =3D~ /.gz$/ ? "gzip -dc $filestr |" : $filestr))= )) { - $errormessage =3D "$Lang::tr{'date not in logs'}: $filestr $Lang::tr= {'could not be opened'}"; - $skip=3D1; - # Note: This is in case the log does not exist for that date + $errormessage =3D "$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'co= uld not be opened'}"; + $skip=3D1; + # Note: This is in case the log does not exist for that date } my $lines =3D 0; my @log=3D(); if (!$skip) { - while () - { - if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN= =3D.*)$/) { - $log[$lines] =3D $_; - $lines++; - } - } - close (FILE); + while () + { + if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=3D.*)$/)= { + $log[$lines] =3D $_; + $lines++; + } + } + close (FILE); } $skip=3D0; if ($multifile) { - $datediff=3D$datediff-1; - if ($datediff=3D=3D0) { - $filestr=3D"/var/log/messages"; - } else { - $filestr=3D"/var/log/messages.$datediff"; - $filestr =3D "$filestr.gz" if -f "$filestr.gz"; - } - if (!(open (FILE,($filestr =3D~ /.gz$/ ? "gzip -dc $filestr |" : $fi= lestr)))) { - $errormessage=3D"$Lang::tr{'date not in logs'}: $filestr $La= ng::tr{'could not be opened'}"; - $skip=3D1; - } - if (!$skip) { - while () { - if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kerne= l:.*(IN=3D.*)$/) { - $log[$lines] =3D $_; - $lines++; - } - } - close (FILE); - } + $datediff=3D$datediff-1; + if ($datediff=3D=3D0) { + $filestr=3D"/var/log/messages"; + } else { + $filestr=3D"/var/log/messages.$datediff"; + $filestr =3D "$filestr.gz" if -f "$filestr.gz"; + } + if (!(open (FILE,($filestr =3D~ /.gz$/ ? "gzip -dc $filestr |" : $filest= r)))) { + $errormessage=3D"$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'= could not be opened'}"; + $skip=3D1; + } + if (!$skip) { + while () { + if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=3D.*= )$/) { + $log[$lines] =3D $_; + $lines++; + } + } + close (FILE); + } } my $MODNAME=3D"fwlogs"; @@ -217,9 +217,9 @@ my $MODNAME=3D"fwlogs"; if ($errormessage) { - &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); - print "$errormessage \n"; - &Header::closebox(); + &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); + print "$errormessage \n"; + &Header::closebox(); } &Header::openbox('100%', 'left', "$Lang::tr{'settings'}"); @@ -228,33 +228,35 @@ print <
$Lang::tr{'month'}:  - $Lang::tr{'month'}:  +  $Lang::tr{'da= y'}:  - +  $Lang::tr{'day'}:=   +
"; - - # Dont show details button for "unknown" location. - if ($key[$s] ne 'unknown') { - print"
"; - print""; - print""; - print""; - print"
"; - } - elsif ($key[$s] eq 'unknown') { - print "unknown"; - } - # Looks dangerous to use hardcoded interface names here. Probably needs fi= xing. - if ($key[$s] eq 'blue0' || $key[$s] eq 'green0' || $key[$s] eq 'orange0' )= { - print "
$key[$s]3D'$key[$s]=
"; + + # Dont show details button for "unknown" location. + if ($key[$s] ne 'unknown') { + print"
"; + print""; + print""; + print""; + print"
"; + } + elsif ($key[$s] eq 'unknown') { + print "unknown"; + } + # Looks dangerous to use hardcoded interface names here. Probably needs = fixing. + if ($key[$s] eq 'blue0' || $key[$s] eq 'green0' || $key[$s] eq 'orange0'= ) { print "
$key[$s]$value[$s]$percent
3D'$key=$key[$s]$value[$s]$percent
$Lang::tr{'other countries'}$dif$percent
$Lang::tr{'other countries'}$dif$percent
- - + - - + + "; + + my $gi =3D Geo::IP::PurePerl->new(); + my $ccode =3D $gi->country_code_by_name($key[$s]); + my $fcode =3D lc($ccode); - my $gi =3D Geo::IP::PurePerl->new(); - my $ccode =3D $gi->country_code_by_name($key[$s]); - my $fcode =3D lc($ccode); - - $color++; - print ""; - print ""; - - # Get flag icon for of the country. - my $flag_icon =3D &GeoIP::get_flag_icon($ccode); - - if ( $flag_icon ) { - print ""; - } else { - print ""; - } - - print ""; - print ""; - print ""; - } + $color++; + print ""; + print ""; + + # Get flag icon for of the country. + my $flag_icon =3D &GeoIP::get_flag_icon($ccode); + + if ( $flag_icon ) { + print ""; + } else { + print ""; + } + + print ""; + print ""; + print ""; +} if($cgiparams{'otherspie'} =3D=3D 2 ){} else{ - # colors are numbered 1 to 10 - my $colorIndex =3D ($color % 10) + 1; - $col=3D"bgcolor=3D'$color{\"color$colorIndex\"}'"; - print ""; - -if ( $linesjc ne "0") -{ -my $dif; -$dif =3D $linesjc - $total; -$percent =3D $dif * 100 / $linesjc; -$percent =3D sprintf("%.f", $percent); -print < - - - - - + # colors are numbered 1 to 10 + my $colorIndex =3D ($color % 10) + 1; + $col=3D"bgcolor=3D'$color{\"color$colorIndex\"}'"; + print ""; + + if ( $linesjc ne "0") + { + my $dif; + $dif =3D $linesjc - $total; + $percent =3D $dif * 100 / $linesjc; + $percent =3D sprintf("%.f", $percent); + print < + + + + + END -; -} + ; + } } print < @@ -490,20 +492,20 @@ END &Header::closepage(); sub findkey { - my $v; - foreach $v (@keytabjc) { - if ($tabjc{$v} eq $_[0]) { - delete $tabjc{$v}; - $key[$indice] =3D "$v"; - $value[$indice] =3D $_[0]; - $indice++; - last; - } - } + my $v; + foreach $v (@keytabjc) { + if ($tabjc{$v} eq $_[0]) { + delete $tabjc{$v}; + $key[$indice] =3D "$v"; + $value[$indice] =3D $_[0]; + $indice++; + last; + } + } } sub checkversion { - #Automatic Updates is disabled - return "0","0"; + #Automatic Updates is disabled + return "0","0"; } diff --git a/html/cgi-bin/logs.cgi/firewalllogport.dat b/html/cgi-bin/logs.cg= i/firewalllogport.dat index 583c1b3..fbc92e4 100644 --- a/html/cgi-bin/logs.cgi/firewalllogport.dat +++ b/html/cgi-bin/logs.cgi/firewalllogport.dat @@ -8,7 +8,7 @@ # page inspired from the initial firewalllog.dat # # Modified for IPFire by Christian Schmidt -# and Michael Tremer (www.ipfire.org) +# and Michael Tremer (www.ipfire.org) use strict; @@ -40,11 +40,11 @@ $cgiparams{'showpie'} =3D 1; $cgiparams{'sortcolumn'} =3D 1; my @shortmonths =3D ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug= ', - 'Sep', 'Oct', 'Nov', 'Dec' ); + 'Sep', 'Oct', 'Nov', 'Dec' ); my @longmonths =3D ( $Lang::tr{'january'}, $Lang::tr{'february'}, $Lang::tr= {'march'}, - $Lang::tr{'april'}, $Lang::tr{'may'}, $Lang::tr{'june'}, $Lang::tr{'= july'}, $Lang::tr{'august'}, - $Lang::tr{'september'}, $Lang::tr{'october'}, $Lang::tr{'november'}, - $Lang::tr{'december'} ); + $Lang::tr{'april'}, $Lang::tr{'may'}, $Lang::tr{'june'}, $Lang::tr{'july= '}, $Lang::tr{'august'}, + $Lang::tr{'september'}, $Lang::tr{'october'}, $Lang::tr{'november'}, + $Lang::tr{'december'} ); my @now =3D localtime(); my $dow =3D $now[6]; @@ -70,81 +70,81 @@ if ($cgiparams{'sortcolumn'} !=3D 0) { $settings{'sortcol= umn'} =3D $cgiparams{'sortc if ($cgiparams{'ACTION'} eq $Lang::tr{'save'}) { - &General::writehash("${General::swroot}/fwlogs/portsettings", \%settings); + &General::writehash("${General::swroot}/fwlogs/portsettings", \%settings); } my $start =3D -1; if ($ENV{'QUERY_STRING'} && $cgiparams{'ACTION'} ne $Lang::tr{'update'}) { - my @temp =3D split(',',$ENV{'QUERY_STRING'}); - $start =3D $temp[0]; - $cgiparams{'MONTH'} =3D $temp[1]; - $cgiparams{'DAY'} =3D $temp[2]; + my @temp =3D split(',',$ENV{'QUERY_STRING'}); + $start =3D $temp[0]; + $cgiparams{'MONTH'} =3D $temp[1]; + $cgiparams{'DAY'} =3D $temp[2]; } if (!($cgiparams{'MONTH'} =3D~ /^(0|1|2|3|4|5|6|7|8|9|10|11)$/) || !($cgiparams{'DAY'} =3D~ /^(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|1= 8|19|20|21|22|23|24|25|26|27|28|29|30|31)$/)) { - $cgiparams{'DAY'} =3D $now[3]; - $cgiparams{'MONTH'} =3D $now[4]; + $cgiparams{'DAY'} =3D $now[3]; + $cgiparams{'MONTH'} =3D $now[4]; } elsif($cgiparams{'ACTION'} eq '>>') { - my @temp_then=3D(); - my @temp_now =3D localtime(time); - $temp_now[4] =3D $cgiparams{'MONTH'}; - $temp_now[3] =3D $cgiparams{'DAY'}; - @temp_then =3D localtime(POSIX::mktime(@temp_now) + 86400); - ## Retrieve the same time on the next day - - ## 86400 seconds in a day - $cgiparams{'MONTH'} =3D $temp_then[4]; - $cgiparams{'DAY'} =3D $temp_then[3]; + my @temp_then=3D(); + my @temp_now =3D localtime(time); + $temp_now[4] =3D $cgiparams{'MONTH'}; + $temp_now[3] =3D $cgiparams{'DAY'}; + @temp_then =3D localtime(POSIX::mktime(@temp_now) + 86400); + ## Retrieve the same time on the next day - + ## 86400 seconds in a day + $cgiparams{'MONTH'} =3D $temp_then[4]; + $cgiparams{'DAY'} =3D $temp_then[3]; } elsif($cgiparams{'ACTION'} eq '<<') { - my @temp_then=3D(); - my @temp_now =3D localtime(time); - $temp_now[4] =3D $cgiparams{'MONTH'}; - $temp_now[3] =3D $cgiparams{'DAY'}; - @temp_then =3D localtime(POSIX::mktime(@temp_now) - 86400); - ## Retrieve the same time on the previous day - - ## 86400 seconds in a day - $cgiparams{'MONTH'} =3D $temp_then[4]; - $cgiparams{'DAY'} =3D $temp_then[3]; + my @temp_then=3D(); + my @temp_now =3D localtime(time); + $temp_now[4] =3D $cgiparams{'MONTH'}; + $temp_now[3] =3D $cgiparams{'DAY'}; + @temp_then =3D localtime(POSIX::mktime(@temp_now) - 86400); + ## Retrieve the same time on the previous day - + ## 86400 seconds in a day + $cgiparams{'MONTH'} =3D $temp_then[4]; + $cgiparams{'DAY'} =3D $temp_then[3]; } if (($cgiparams{'DAY'} ne $now[3]) || ($cgiparams{'MONTH'} ne $now[4])) { - my @then =3D (); - if ( ( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now= [3]) || - ( $cgiparams{'MONTH'} > $now[4] ) ) { - @then =3D localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'= }, $cgiparams{'MONTH'}, $year - 1901 )); - } else { - @then =3D localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'= }, $cgiparams{'MONTH'}, $year - 1900 )); - } - $tdoy =3D $then[7]; - my $lastleap=3D($year-1)%4; - if ($tdoy>$doy) { - if ($lastleap =3D=3D 0 && $tdoy < 60) { - $doy=3D$tdoy+366; - } else { - $doy=3D$doy+365; - } - } + my @then =3D (); + if ( ( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3])= || + ( $cgiparams{'MONTH'} > $now[4] ) ) { + @then =3D localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgip= arams{'MONTH'}, $year - 1901 )); + } else { + @then =3D localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgip= arams{'MONTH'}, $year - 1900 )); + } + $tdoy =3D $then[7]; + my $lastleap=3D($year-1)%4; + if ($tdoy>$doy) { + if ($lastleap =3D=3D 0 && $tdoy < 60) { + $doy=3D$tdoy+366; + } else { + $doy=3D$doy+365; + } + } } my $datediff=3D0; my $dowd=3D0; my $multifile=3D0; if ($tdoy ne $doy) { - $datediff=3Dint(($doy-$tdoy)/7); - $dowd=3D($doy-$tdoy)%7; - if (($dow-$dowd)<1) { - $datediff=3D$datediff+1; - } - if (($dow-$dowd)=3D=3D0) { - $multifile=3D1; - } + $datediff=3Dint(($doy-$tdoy)/7); + $dowd=3D($doy-$tdoy)%7; + if (($dow-$dowd)<1) { + $datediff=3D$datediff+1; + } + if (($dow-$dowd)=3D=3D0) { + $multifile=3D1; + } } my $monthstr =3D $shortmonths[$cgiparams{'MONTH'}]; @@ -152,62 +152,62 @@ my $longmonthstr =3D $longmonths[$cgiparams{'MONTH'}]; my $day =3D $cgiparams{'DAY'}; my $daystr=3D''; if ($day <=3D 9) { - $daystr =3D " $day"; } + $daystr =3D " $day"; } else { - $daystr =3D $day; + $daystr =3D $day; } my $skip=3D0; my $filestr=3D''; if ($datediff=3D=3D0) { - $filestr=3D"/var/log/messages"; + $filestr=3D"/var/log/messages"; } else { - $filestr=3D"/var/log/messages.$datediff"; - $filestr =3D "$filestr.gz" if -f "$filestr.gz"; + $filestr=3D"/var/log/messages.$datediff"; + $filestr =3D "$filestr.gz" if -f "$filestr.gz"; } if (!(open (FILE,($filestr =3D~ /.gz$/ ? "gzip -dc $filestr |" : $filestr))= )) { - $errormessage =3D "$Lang::tr{'date not in logs'}: $filestr $Lang::tr= {'could not be opened'}"; - $skip=3D1; - # Note: This is in case the log does not exist for that date + $errormessage =3D "$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'co= uld not be opened'}"; + $skip=3D1; + # Note: This is in case the log does not exist for that date } my $lines =3D 0; my @log=3D(); if (!$skip) { - while () - { - if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN= =3D.*)$/) { - $log[$lines] =3D $_; - $lines++; - } - } - close (FILE); + while () + { + if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=3D.*)$/)= { + $log[$lines] =3D $_; + $lines++; + } + } + close (FILE); } $skip=3D0; if ($multifile) { - $datediff=3D$datediff-1; - if ($datediff=3D=3D0) { - $filestr=3D"/var/log/messages"; - } else { - $filestr=3D"/var/log/messages.$datediff"; - $filestr =3D "$filestr.gz" if -f "$filestr.gz"; - } - if (!(open (FILE,($filestr =3D~ /.gz$/ ? "gzip -dc $filestr |" : $fi= lestr)))) { - $errormessage=3D"$Lang::tr{'date not in logs'}: $filestr $La= ng::tr{'could not be opened'}"; - $skip=3D1; - } - if (!$skip) { - while () { - if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kerne= l:.*(IN=3D.*)$/) { - $log[$lines] =3D $_; - $lines++; - } - } - close (FILE); - } + $datediff=3D$datediff-1; + if ($datediff=3D=3D0) { + $filestr=3D"/var/log/messages"; + } else { + $filestr=3D"/var/log/messages.$datediff"; + $filestr =3D "$filestr.gz" if -f "$filestr.gz"; + } + if (!(open (FILE,($filestr =3D~ /.gz$/ ? "gzip -dc $filestr |" : $filest= r)))) { + $errormessage=3D"$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'= could not be opened'}"; + $skip=3D1; + } + if (!$skip) { + while () { + if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=3D.*= )$/) { + $log[$lines] =3D $_; + $lines++; + } + } + close (FILE); + } } my $MODNAME=3D"fwlogs"; @@ -217,9 +217,9 @@ my $MODNAME=3D"fwlogs"; &Header::openbigbox('100%', 'left', '', $errormessage); if ($errormessage) { - &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); - print "$errormessage \n"; - &Header::closebox(); + &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); + print "$errormessage \n"; + &Header::closebox(); } &Header::openbox('100%', 'left', "$Lang::tr{'settings'}"); @@ -228,33 +228,33 @@ print <
$Lang::tr{'month'}:  - $Lang::tr{'month'}:  +  $Lang::tr{'da= y'}:  - +  $Lang::tr{'day'}:=   +
$key[$s]3D'$ccode'$value[$s]$percent
$key[$s]3D'$ccode'$value[$s]$percent
$Lang::tr{'otherip'}$dif$percent
$Lang::tr{'otherip'}$dif$percent
- - + - - + + "; - print ""; - print ""; - print ""; - print ""; + $show++; + $percent =3D $value[$s] * 100 / $linesjc; + $percent =3D sprintf("%.f", $percent); + $total =3D $total + $value[$s]; + # colors are numbered 1 to 10 + my $colorIndex =3D ($color % 10) + 1; + $col=3D"bgcolor=3D'$color{\"color$colorIndex\"}'"; + print ""; + + $color++; + print ""; + print ""; + print ""; + print ""; + print ""; } if($cgiparams{'otherspie'} =3D=3D 2 ){} else{ - # colors are numbered 1 to 10 - my $colorIndex =3D ($color % 10) + 1; - $col=3D"bgcolor=3D'$color{\"color$colorIndex\"}'"; - print ""; - -if ( $linesjc ne "0") -{ -my $dif; -$dif =3D $linesjc - $total; -$percent =3D $dif * 100 / $linesjc; -$percent =3D sprintf("%.f", $percent); -print < - - - - + # colors are numbered 1 to 10 + my $colorIndex =3D ($color % 10) + 1; + $col=3D"bgcolor=3D'$color{\"color$colorIndex\"}'"; + print ""; + + if ( $linesjc ne "0") { + my $dif; + $dif =3D $linesjc - $total; + $percent =3D $dif * 100 / $linesjc; + $percent =3D sprintf("%.f", $percent); + print < + + + + END -; -} + ; + } } print < @@ -475,20 +474,20 @@ END &Header::closepage(); sub findkey { - my $v; - foreach $v (@keytabjc) { - if ($tabjc{$v} eq $_[0]) { - delete $tabjc{$v}; - $key[$indice] =3D "$v"; - $value[$indice] =3D $_[0]; - $indice++; - last; - } - } + my $v; + foreach $v (@keytabjc) { + if ($tabjc{$v} eq $_[0]) { + delete $tabjc{$v}; + $key[$indice] =3D "$v"; + $value[$indice] =3D $_[0]; + $indice++; + last; + } + } } sub checkversion { - #Automatic Updates is disabled - return "0","0"; + #Automatic Updates is disabled + return "0","0"; } diff --git a/html/cgi-bin/logs.cgi/showrequestfromcountry.dat b/html/cgi-bin/= logs.cgi/showrequestfromcountry.dat index 27e7697..cd97f87 100644 --- a/html/cgi-bin/logs.cgi/showrequestfromcountry.dat +++ b/html/cgi-bin/logs.cgi/showrequestfromcountry.dat @@ -69,60 +69,60 @@ if (!($cgiparams{'MONTH'} =3D~ /^(0|1|2|3|4|5|6|7|8|9|10|= 11)$/) || } elsif($cgiparams{'ACTION'} eq '>>') { - my @temp_then=3D(); - my @temp_now =3D localtime(time); - $temp_now[4] =3D $cgiparams{'MONTH'}; - $temp_now[3] =3D $cgiparams{'DAY'}; - @temp_then =3D localtime(POSIX::mktime(@temp_now) + 86400); - ## Retrieve the same time on the next day - - ## 86400 seconds in a day - $cgiparams{'MONTH'} =3D $temp_then[4]; - $cgiparams{'DAY'} =3D $temp_then[3]; + my @temp_then=3D(); + my @temp_now =3D localtime(time); + $temp_now[4] =3D $cgiparams{'MONTH'}; + $temp_now[3] =3D $cgiparams{'DAY'}; + @temp_then =3D localtime(POSIX::mktime(@temp_now) + 86400); + ## Retrieve the same time on the next day - + ## 86400 seconds in a day + $cgiparams{'MONTH'} =3D $temp_then[4]; + $cgiparams{'DAY'} =3D $temp_then[3]; } elsif($cgiparams{'ACTION'} eq '<<') { - my @temp_then=3D(); - my @temp_now =3D localtime(time); - $temp_now[4] =3D $cgiparams{'MONTH'}; - $temp_now[3] =3D $cgiparams{'DAY'}; - @temp_then =3D localtime(POSIX::mktime(@temp_now) - 86400); - ## Retrieve the same time on the previous day - - ## 86400 seconds in a day - $cgiparams{'MONTH'} =3D $temp_then[4]; - $cgiparams{'DAY'} =3D $temp_then[3]; + my @temp_then=3D(); + my @temp_now =3D localtime(time); + $temp_now[4] =3D $cgiparams{'MONTH'}; + $temp_now[3] =3D $cgiparams{'DAY'}; + @temp_then =3D localtime(POSIX::mktime(@temp_now) - 86400); + ## Retrieve the same time on the previous day - + ## 86400 seconds in a day + $cgiparams{'MONTH'} =3D $temp_then[4]; + $cgiparams{'DAY'} =3D $temp_then[3]; } if (($cgiparams{'DAY'} ne $now[3]) || ($cgiparams{'MONTH'} ne $now[4])) { - my @then =3D (); - if ( ( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now= [3]) || - ( $cgiparams{'MONTH'} > $now[4] ) ) { - @then =3D localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'= }, $cgiparams{'MONTH'}, $year - 1901 )); - } else { - @then =3D localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'= }, $cgiparams{'MONTH'}, $year - 1900 )); - } - $tdoy =3D $then[7]; - my $lastleap=3D($year-1)%4; - if ($tdoy>$doy) { - if ($lastleap =3D=3D 0 && $tdoy < 60) { - $doy=3D$tdoy+366; - } else { - $doy=3D$doy+365; - } - } + my @then =3D (); + if ( ( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3])= || + ( $cgiparams{'MONTH'} > $now[4] ) ) { + @then =3D localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgip= arams{'MONTH'}, $year - 1901 )); + } else { + @then =3D localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgip= arams{'MONTH'}, $year - 1900 )); + } + $tdoy =3D $then[7]; + my $lastleap=3D($year-1)%4; + if ($tdoy>$doy) { + if ($lastleap =3D=3D 0 && $tdoy < 60) { + $doy=3D$tdoy+366; + } else { + $doy=3D$doy+365; + } + } } my $datediff=3D0; my $dowd=3D0; my $multifile=3D0; if ($tdoy ne $doy) { - $datediff=3Dint(($doy-$tdoy)/7); - $dowd=3D($doy-$tdoy)%7; - if (($dow-$dowd)<1) { - $datediff=3D$datediff+1; - } - if (($dow-$dowd)=3D=3D0) { - $multifile=3D1; - } + $datediff=3Dint(($doy-$tdoy)/7); + $dowd=3D($doy-$tdoy)%7; + if (($dow-$dowd)<1) { + $datediff=3D$datediff+1; + } + if (($dow-$dowd)=3D=3D0) { + $multifile=3D1; + } } my $monthstr =3D $shortmonths[$cgiparams{'MONTH'}]; @@ -138,16 +138,16 @@ else { my $skip=3D0; my $filestr=3D''; if ($datediff=3D=3D0) { - $filestr=3D"/var/log/messages"; + $filestr=3D"/var/log/messages"; } else { - $filestr=3D"/var/log/messages.$datediff"; - $filestr =3D "$filestr.gz" if -f "$filestr.gz"; + $filestr=3D"/var/log/messages.$datediff"; + $filestr =3D "$filestr.gz" if -f "$filestr.gz"; } if (!(open (FILE,($filestr =3D~ /.gz$/ ? "gzip -dc $filestr |" : $filestr))= )) { - $errormessage =3D "$Lang::tr{'date not in logs'}: $filestr $Lang::tr= {'could not be opened'}"; - $skip=3D1; - # Note: This is in case the log does not exist for that date + $errormessage =3D "$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'co= uld not be opened'}"; + $skip=3D1; + # Note: This is in case the log does not exist for that date } my $lines =3D 0; my @log=3D(); @@ -156,78 +156,77 @@ my $gi =3D Geo::IP::PurePerl->new(); if (!$skip) { - while () - { - # First check whether valid log line (date, day) - if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=3D.*)$= /) { - # If ipv6 uses bridge, then use PHYSIN otherwise use IN - if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(PHYS= IN=3D.*)$/) {} - elsif (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN= =3D.*)$/) {} - my $packet =3D $2; - my $iface =3D ''; - my $srcaddr =3D ''; - # If ipv6 uses bridge, use PHYSIN otherwise IN - if ($packet =3D~ /PHYSIN=3D(\w+)/) { $iface =3D $1; } elsif ($pa= cket =3D~ /IN=3D(\w+)/) { $iface =3D $1; } - # Extract ipv4 and ipv6 addresses - if (($packet =3D~ /SRC\=3D(([\d]{1,3})(\.([\d]{1,3})){3})/) or (= $packet =3D~ /SRC\=3D(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { - $srcaddr =3D $1; - }; - - if($iface eq $country) { - # iface matches country code - $log[$lines] =3D $_; - $lines++; - } - elsif($srcaddr ne '') { - # or srcaddr matches country code - my $ccode =3D $gi->country_code_by_name($srcaddr); - if($ccode eq uc($country)){ - $log[$lines] =3D $_; - $lines++; - } - } - } + while () { + # First check whether valid log line (date, day) + if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=3D.*)$/)= { + # If ipv6 uses bridge, then use PHYSIN otherwise use IN + if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(PHYS= IN=3D.*)$/) {} + elsif (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN= =3D.*)$/) {} + my $packet =3D $2; + my $iface =3D ''; + my $srcaddr =3D ''; + # If ipv6 uses bridge, use PHYSIN otherwise IN + if ($packet =3D~ /PHYSIN=3D(\w+)/) { $iface =3D $1; } elsif ($pa= cket =3D~ /IN=3D(\w+)/) { $iface =3D $1; } + # Extract ipv4 and ipv6 addresses + if (($packet =3D~ /SRC\=3D(([\d]{1,3})(\.([\d]{1,3})){3})/) or (= $packet =3D~ /SRC\=3D(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { + $srcaddr =3D $1; + } + + if($iface eq $country) { + # iface matches country code + $log[$lines] =3D $_; + $lines++; + } + elsif($srcaddr ne '') { + # or srcaddr matches country code + my $ccode =3D $gi->country_code_by_name($srcaddr); + if($ccode eq uc($country)){ + $log[$lines] =3D $_; + $lines++; + } + } + } } close (FILE); } $skip=3D0; if ($multifile) { - $datediff=3D$datediff-1; - if ($datediff=3D=3D0) { - $filestr=3D"/var/log/messages"; - } else { - $filestr=3D"/var/log/messages.$datediff"; - $filestr =3D "$filestr.gz" if -f "$filestr.gz"; - } - if (!(open (FILE,($filestr =3D~ /.gz$/ ? "gzip -dc $filestr |" : $fi= lestr)))) { - $errormessage=3D"$Lang::tr{'date not in logs'}: $filestr $La= ng::tr{'could not be opened'}"; - $skip=3D1; - } - if (!$skip) { + $datediff=3D$datediff-1; + if ($datediff=3D=3D0) { + $filestr=3D"/var/log/messages"; + } else { + $filestr=3D"/var/log/messages.$datediff"; + $filestr =3D "$filestr.gz" if -f "$filestr.gz"; + } + if (!(open (FILE,($filestr =3D~ /.gz$/ ? "gzip -dc $filestr |" : $filest= r)))) { + $errormessage=3D"$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'= could not be opened'}"; + $skip=3D1; + } + if (!$skip) { while () { - # Check if valid log line (date, day) - if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=3D.*)= $/) { - my $iface =3D ''; - # If ipv6 uses bridge, then use PHYSIN otherwise IN - if ($_ =3D~ /PHYSIN=3D(\w+)/) { $iface =3D $1; } elsif (= $_ =3D~ /IN=3D(\w+)/) { $iface =3D $1; } - - if($iface eq $country) { - # iface matches country code - $log[$lines] =3D $_; - $lines++; - } - # extract ipv4 and ipv6 address - elsif (($_ =3D~ /SRC\=3D(([\d]{1,3})(\.([\d]{1,3})){3})/= ) or ($_ =3D~ /SRC\=3D(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { - my $srcaddr=3D$1; - my $ccode =3D $gi->country_code_by_name($srcaddr); - if($ccode eq uc($country)){ - # or srcaddr matches country code - $log[$lines] =3D $_; - $lines++; - } - } - } + # Check if valid log line (date, day) + if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=3D.= *)$/) { + my $iface =3D ''; + # If ipv6 uses bridge, then use PHYSIN otherwise IN + if ($_ =3D~ /PHYSIN=3D(\w+)/) { $iface =3D $1; } elsif ($_ = =3D~ /IN=3D(\w+)/) { $iface =3D $1; } + + if($iface eq $country) { + # iface matches country code + $log[$lines] =3D $_; + $lines++; + } + # extract ipv4 and ipv6 address + elsif (($_ =3D~ /SRC\=3D(([\d]{1,3})(\.([\d]{1,3})){3})/) or= ($_ =3D~ /SRC\=3D(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { + my $srcaddr=3D$1; + my $ccode =3D $gi->country_code_by_name($srcaddr); + if($ccode eq uc($country)){ + # or srcaddr matches country code + $log[$lines] =3D $_; + $lines++; + } + } + } } close (FILE); } @@ -259,7 +258,8 @@ for ($month =3D 0; $month < 12; $month++) { print "\t\n"; } print <$Lang::tr{'firewall hits'} $longmonthstr $daystr: $lines"; if ($start =3D=3D -1) { - $start =3D $lines - ${Header::viewsize}; } + $start =3D $lines - ${Header::viewsize}; +} if ($start >=3D $lines - ${Header::viewsize}) { $start =3D $lines - ${Heade= r::viewsize}; }; if ($start < 0) { $start =3D 0; } @@ -331,78 +332,80 @@ if ($logsettings{'LOGVIEW_REVERSE'} eq 'on') { @slice = =3D reverse @slice; } $lines =3D 0; foreach $_ (@slice) { - $a =3D $_; - # If ipv6 uses bridge, use PHYSIN otherwise use IN - if (/^... (..) (..:..:..) [\w\-]+ kernel:(.*)(PHYSIN=3D.*)$/) {} - elsif (/^... (..) (..:..:..) [\w\-]+ kernel:(.*)(IN=3D.*)$/) {}; - my $packet =3D $4; - my $iface =3D ''; - # If ipv6 uses bridge, use PHYSIN otherwise use IN - if ($packet =3D~ /PHYSIN=3D(\w+)/) { $iface =3D $1; } elsif ($packet =3D~ = /IN=3D(\w+)/) { $iface =3D $1; } - if ( $1 =3D~ /2./ ){ $iface=3D""; } - my $srcaddr =3D ''; - # Extract ipv4 and ipv6 addresses - if (($packet =3D~ /SRC\=3D(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($packet = =3D~ /SRC\=3D(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { - $srcaddr =3D $1; - }; - - if($iface eq $country || $srcaddr ne '') { - my $ccode=3D''; - if($iface ne $country) { - $ccode =3D $gi->country_code_by_name($srcaddr); - } - if($iface eq $country || $ccode eq uc($country)) { - my $chain =3D ''; - my $in =3D '-'; my $out =3D '-'; - my $srcaddr =3D ''; my $dstaddr =3D ''; - my $protostr =3D ''; - my $srcport =3D ''; my $dstport =3D ''; - - # If ipv6 uses bridge, the use PHYSIN otherwise use IN - if ($_ =3D~ /(^.* ..:..:..) [\w\-]+ kernel:(.*)(IN=3D.*)(PHYSIN=3D.= *)$/) {} - elsif ($_ =3D~ /(^.* ..:..:..) [\w\-]+ kernel:(.*)(IN=3D.*)$/) {} - my $timestamp =3D $1; my $chain =3D $2; my $packet =3D $3; - $timestamp =3D~ /(...) (..) (..:..:..)/; - my $month =3D $1; my $day =3D $2; my $time =3D $3; - - # If ipv6 uses bridge, use PHYSIN and PHYSOUT, otherwise use IN and OUT - if ($a =3D~ /PHYSIN=3D(\w+)/) { $iface =3D $1; } elsif ($a =3D~ /IN= =3D(\w+)/) { $iface =3D $1; } - if ($a =3D~ /PHYSOUT=3D(\w+)/) { $out =3D $1; } elsif ($a =3D~ /OUT= =3D(\w+)/) { $out =3D $1; } - # Extract ipv4 and ipv6 addresses - if (($a =3D~ /SRC\=3D(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($a =3D~ /SR= C\=3D(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { $srcaddr =3D $1; } - if (($a =3D~ /DST\=3D(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($a =3D~ /DS= T\=3D(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { $dstaddr =3D $1; } - if ($a =3D~ /PROTO\=3D(\w+)/) { $protostr =3D $1; } - my $protostrlc =3D lc($protostr); - if ($a =3D~ /SPT\=3D([\d\.]+)/){ $srcport =3D $1; } - if ($a =3D~ /DPT\=3D([\d\.]+)/){ $dstport =3D $1; } - - if ($lines % 2) { - print "\n"; } - else { - print "\n"; } - print <$time - - - - - - - - + $a =3D $_; + # If ipv6 uses bridge, use PHYSIN otherwise use IN + if (/^... (..) (..:..:..) [\w\-]+ kernel:(.*)(PHYSIN=3D.*)$/) {} + elsif (/^... (..) (..:..:..) [\w\-]+ kernel:(.*)(IN=3D.*)$/) {}; + my $packet =3D $4; + my $iface =3D ''; + # If ipv6 uses bridge, use PHYSIN otherwise use IN + if ($packet =3D~ /PHYSIN=3D(\w+)/) { $iface =3D $1; } elsif ($packet =3D= ~ /IN=3D(\w+)/) { $iface =3D $1; } + if ( $1 =3D~ /2./ ){ $iface=3D""; } + my $srcaddr =3D ''; + # Extract ipv4 and ipv6 addresses + if (($packet =3D~ /SRC\=3D(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($packet = =3D~ /SRC\=3D(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { + $srcaddr =3D $1; + }; + + if($iface eq $country || $srcaddr ne '') { + my $ccode=3D''; + if($iface ne $country) { + $ccode =3D $gi->country_code_by_name($srcaddr); + } + if($iface eq $country || $ccode eq uc($country)) { + my $chain =3D ''; + my $in =3D '-'; my $out =3D '-'; + my $srcaddr =3D ''; my $dstaddr =3D ''; + my $protostr =3D ''; + my $srcport =3D ''; my $dstport =3D ''; + + # If ipv6 uses bridge, the use PHYSIN otherwise use IN + if ($_ =3D~ /(^.* ..:..:..) [\w\-]+ kernel:(.*)(IN=3D.*)(PHYS= IN=3D.*)$/) {} + elsif ($_ =3D~ /(^.* ..:..:..) [\w\-]+ kernel:(.*)(IN=3D.*)$/) {} + my $timestamp =3D $1; my $chain =3D $2; my $packet =3D $3; + $timestamp =3D~ /(...) (..) (..:..:..)/; + my $month =3D $1; my $day =3D $2; my $time =3D $3; + + # If ipv6 uses bridge, use PHYSIN and PHYSOUT, otherwise use IN = and OUT + if ($a =3D~ /PHYSIN=3D(\w+)/) { $iface =3D $1; } elsif ($a =3D~= /IN=3D(\w+)/) { $iface =3D $1; } + if ($a =3D~ /PHYSOUT=3D(\w+)/) { $out =3D $1; } elsif ($a =3D~= /OUT=3D(\w+)/) { $out =3D $1; } + # Extract ipv4 and ipv6 addresses + if (($a =3D~ /SRC\=3D(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($a = =3D~ /SRC\=3D(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { $srcaddr = =3D $1; } + if (($a =3D~ /DST\=3D(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($a = =3D~ /DST\=3D(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { $dstaddr = =3D $1; } + if ($a =3D~ /PROTO\=3D(\w+)/) { $protostr =3D $1; } + my $protostrlc =3D lc($protostr); + if ($a =3D~ /SPT\=3D([\d\.]+)/){ $srcport =3D $1; } + if ($a =3D~ /DPT\=3D([\d\.]+)/){ $dstport =3D $1; } + + if ($lines % 2) { + print "\n"; + } + else { + print "\n"; + } + print <$time + + + + + + + + END - ; - $lines++; - } - } + ; + $lines++; + } + } } print < - + print < + END -; + ; - print "\n"; + print "\n"; - print "\n"; + print "
$Lang::tr{'month'}:  - $Lang::tr{'month'}:  +  $Lang::tr{'da= y'}:  - +  $Lang::tr{'day'}:=   +
$key[$s]$value[$s]$percent
$key[$s]$value[$s]$percent
$Lang::tr{'otherport'}$dif$percent
$Lang::tr{'otherport'}$dif$percent
$chain$iface$protostr - - -
$sr= caddr
-
$srcport - - -
$ds= taddr
-
$dstport
$chain$iface$protostr + + +
$srcaddr
+
$srcport + + +
$dstaddr
+
$dstport
"; - if ($prev !=3D -1) { - print "$Lang::tr{'older'}"; } - else { - print "$Lang::tr{'older'}"; } - print ""; + if ($prev !=3D -1) { + print "$Lang::tr{'older'= }"; + } + else { + print "$Lang::tr{'older'}"; + } + print ""; - if ($next !=3D -1) { - print "$Lang::tr{'newer'}"; } - else { - print "$Lang::tr{'newer'}"; } - print ""; + if ($next !=3D -1) { + print "$Lang::tr{'newer'= }"; + } + else { + print "$Lang::tr{'newer'}"; + } -print < -
+ print "\n"; + print < + END -; + ; } diff --git a/html/cgi-bin/logs.cgi/showrequestfromip.dat b/html/cgi-bin/logs.= cgi/showrequestfromip.dat index d7d1ace..154fa40 100644 --- a/html/cgi-bin/logs.cgi/showrequestfromip.dat +++ b/html/cgi-bin/logs.cgi/showrequestfromip.dat @@ -66,60 +66,60 @@ if (!($cgiparams{'MONTH'} =3D~ /^(0|1|2|3|4|5|6|7|8|9|10|= 11)$/) || } elsif($cgiparams{'ACTION'} eq '>>') { - my @temp_then=3D(); - my @temp_now =3D localtime(time); - $temp_now[4] =3D $cgiparams{'MONTH'}; - $temp_now[3] =3D $cgiparams{'DAY'}; - @temp_then =3D localtime(POSIX::mktime(@temp_now) + 86400); - ## Retrieve the same time on the next day - - ## 86400 seconds in a day - $cgiparams{'MONTH'} =3D $temp_then[4]; - $cgiparams{'DAY'} =3D $temp_then[3]; + my @temp_then=3D(); + my @temp_now =3D localtime(time); + $temp_now[4] =3D $cgiparams{'MONTH'}; + $temp_now[3] =3D $cgiparams{'DAY'}; + @temp_then =3D localtime(POSIX::mktime(@temp_now) + 86400); + ## Retrieve the same time on the next day - + ## 86400 seconds in a day + $cgiparams{'MONTH'} =3D $temp_then[4]; + $cgiparams{'DAY'} =3D $temp_then[3]; } elsif($cgiparams{'ACTION'} eq '<<') { - my @temp_then=3D(); - my @temp_now =3D localtime(time); - $temp_now[4] =3D $cgiparams{'MONTH'}; - $temp_now[3] =3D $cgiparams{'DAY'}; - @temp_then =3D localtime(POSIX::mktime(@temp_now) - 86400); - ## Retrieve the same time on the previous day - - ## 86400 seconds in a day - $cgiparams{'MONTH'} =3D $temp_then[4]; - $cgiparams{'DAY'} =3D $temp_then[3]; + my @temp_then=3D(); + my @temp_now =3D localtime(time); + $temp_now[4] =3D $cgiparams{'MONTH'}; + $temp_now[3] =3D $cgiparams{'DAY'}; + @temp_then =3D localtime(POSIX::mktime(@temp_now) - 86400); + ## Retrieve the same time on the previous day - + ## 86400 seconds in a day + $cgiparams{'MONTH'} =3D $temp_then[4]; + $cgiparams{'DAY'} =3D $temp_then[3]; } if (($cgiparams{'DAY'} ne $now[3]) || ($cgiparams{'MONTH'} ne $now[4])) { - my @then =3D (); - if ( ( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now= [3]) || - ( $cgiparams{'MONTH'} > $now[4] ) ) { - @then =3D localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'= }, $cgiparams{'MONTH'}, $year - 1901 )); - } else { - @then =3D localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'= }, $cgiparams{'MONTH'}, $year - 1900 )); - } - $tdoy =3D $then[7]; - my $lastleap=3D($year-1)%4; - if ($tdoy>$doy) { - if ($lastleap =3D=3D 0 && $tdoy < 60) { - $doy=3D$tdoy+366; - } else { - $doy=3D$doy+365; - } - } + my @then =3D (); + if ( ( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3])= || + ( $cgiparams{'MONTH'} > $now[4] ) ) { + @then =3D localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgip= arams{'MONTH'}, $year - 1901 )); + } else { + @then =3D localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgip= arams{'MONTH'}, $year - 1900 )); + } + $tdoy =3D $then[7]; + my $lastleap=3D($year-1)%4; + if ($tdoy>$doy) { + if ($lastleap =3D=3D 0 && $tdoy < 60) { + $doy=3D$tdoy+366; + } else { + $doy=3D$doy+365; + } + } } my $datediff=3D0; my $dowd=3D0; my $multifile=3D0; if ($tdoy ne $doy) { - $datediff=3Dint(($doy-$tdoy)/7); - $dowd=3D($doy-$tdoy)%7; - if (($dow-$dowd)<1) { - $datediff=3D$datediff+1; - } - if (($dow-$dowd)=3D=3D0) { - $multifile=3D1; - } + $datediff=3Dint(($doy-$tdoy)/7); + $dowd=3D($doy-$tdoy)%7; + if (($dow-$dowd)<1) { + $datediff=3D$datediff+1; + } + if (($dow-$dowd)=3D=3D0) { + $multifile=3D1; + } } my $monthstr =3D $shortmonths[$cgiparams{'MONTH'}]; @@ -135,16 +135,16 @@ else { my $skip=3D0; my $filestr=3D''; if ($datediff=3D=3D0) { - $filestr=3D"/var/log/messages"; + $filestr=3D"/var/log/messages"; } else { $filestr=3D"/var/log/messages.$datediff"; $filestr =3D "$filestr.gz" if -f "$filestr.gz"; } if (!(open (FILE,($filestr =3D~ /.gz$/ ? "gzip -dc $filestr |" : $filestr))= )) { - $errormessage =3D "$Lang::tr{'date not in logs'}: $filestr $Lang::tr= {'could not be opened'}"; - $skip=3D1; - # Note: This is in case the log does not exist for that date + $errormessage =3D "$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'co= uld not be opened'}"; + $skip=3D1; + # Note: This is in case the log does not exist for that date } my $lines =3D 0; my @log=3D(); @@ -152,15 +152,14 @@ my $ip =3D $cgiparams{ip}; if (!$skip) { - while () - { + while () { if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=3D.*)$= /) { - if (($_ =3D~ /SRC\=3D(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($= _ =3D~ /SRC\=3D(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { - if($1 eq $ip){ - $log[$lines] =3D $_; - $lines++; - } - } + if (($_ =3D~ /SRC\=3D(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($_ = =3D~ /SRC\=3D(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { + if($1 eq $ip){ + $log[$lines] =3D $_; + $lines++; + } + } } } close (FILE); @@ -168,26 +167,26 @@ if (!$skip) $skip=3D0; if ($multifile) { - $datediff=3D$datediff-1; - if ($datediff=3D=3D0) { - $filestr=3D"/var/log/messages"; - } else { - $filestr=3D"/var/log/messages.$datediff"; - $filestr =3D "$filestr.gz" if -f "$filestr.gz"; - } - if (!(open (FILE,($filestr =3D~ /.gz$/ ? "gzip -dc $filestr |" : $fi= lestr)))) { - $errormessage=3D"$Lang::tr{'date not in logs'}: $filestr $La= ng::tr{'could not be opened'}"; - $skip=3D1; - } - if (!$skip) { + $datediff=3D$datediff-1; + if ($datediff=3D=3D0) { + $filestr=3D"/var/log/messages"; + } else { + $filestr=3D"/var/log/messages.$datediff"; + $filestr =3D "$filestr.gz" if -f "$filestr.gz"; + } + if (!(open (FILE,($filestr =3D~ /.gz$/ ? "gzip -dc $filestr |" : $filest= r)))) { + $errormessage=3D"$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'= could not be opened'}"; + $skip=3D1; + } + if (!$skip) { while () { - if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=3D.= *)$/) { - if (($_ =3D~ /SRC\=3D(([\d]{1,3})(\.([\d]{1,3})){3= })/) or ($_ =3D~ /SRC\=3D(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { - if($1 eq $ip){ - $log[$lines] =3D $_; - $lines++; - } - } + if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=3D.*= )$/) { + if (($_ =3D~ /SRC\=3D(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($= _ =3D~ /SRC\=3D(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { + if($1 eq $ip){ + $log[$lines] =3D $_; + $lines++; + } + } } } close (FILE); @@ -257,7 +256,8 @@ END print "

$Lang::tr{'firewall hits'} $longmonthstr $daystr: $lines"; if ($start =3D=3D -1) { - $start =3D $lines - ${Header::viewsize}; } + $start =3D $lines - ${Header::viewsize}; +} if ($start >=3D $lines - ${Header::viewsize}) { $start =3D $lines - ${Heade= r::viewsize}; }; if ($start < 0) { $start =3D 0; } @@ -290,63 +290,64 @@ my @slice =3D splice(@log, $start, ${Header::viewsize}); if ($logsettings{'LOGVIEW_REVERSE'} eq 'on') { @slice =3D reverse @slice; } $lines =3D 0; -foreach $_ (@slice) -{ - $a =3D $_; - # Check whether valid ipv4 or ipv6 address - if (($_ =3D~ /SRC\=3D(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($_ =3D~ /SRC\= =3D(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { - if($1 eq $ip){ - my $chain =3D ''; - my $in =3D '-'; my $out =3D '-'; - my $srcaddr =3D ''; my $dstaddr =3D ''; - my $protostr =3D ''; - my $srcport =3D ''; my $dstport =3D ''; - - # If ipv6 uses bridge, the use PHYSIN, otherwise use IN - if ($_ =3D~ /(^.* ..:..:..) [\w\-]+ kernel:(.*)(IN=3D.*)(PHYSIN= =3D.*)$/) {} - elsif ($_ =3D~ /(^.* ..:..:..) [\w\-]+ kernel:(.*)(IN=3D.*)$/) {} - my $timestamp =3D $1; my $chain =3D $2; my $packet =3D $3; - $timestamp =3D~ /(...) (..) (..:..:..)/; - my $month =3D $1; my $day =3D $2; my $time =3D $3; - - # If ipv6 uses bridge, the use PHYSIN and PHYSOUT, otherwise use IN = and OUT - if ($a =3D~ /PHYSIN=3D(\w+)/) { $iface =3D $1; } elsif ($a =3D~ /IN= =3D(\w+)/) { $iface =3D $1; } - if ($a =3D~ /PHYSOUT=3D(\w+)/) { $out =3D $1; } elsif ($a =3D~ /OU= T=3D(\w+)/) { $out =3D $1; } - # Detect ipv4 and ipv6 addresses - if (($a =3D~ /SRC\=3D(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($a =3D~ /SRC\= =3D(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { $srcaddr =3D $1; } - if (($a =3D~ /DST\=3D(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($a =3D~ /DST\= =3D(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { $dstaddr =3D $1; } - if ($a =3D~ /PROTO\=3D(\w+)/) { $protostr =3D $1; } - my $protostrlc =3D lc($protostr); - if ($a =3D~ /SPT\=3D([\d\.]+)/){ $srcport =3D $1; } - if ($a =3D~ /DPT\=3D([\d\.]+)/){ $dstport =3D $1; } - - if ($lines % 2) { - print "\n"; } - else { - print "\n"; } - print <$time - $chain - $iface - $protostr - - - -
$srca= ddr
- - $srcport - - - -
$dsta= ddr
- - $dstport - +foreach $_ (@slice) { + $a =3D $_; + # Check whether valid ipv4 or ipv6 address + if (($_ =3D~ /SRC\=3D(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($_ =3D~ /SRC\= =3D(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { + if($1 eq $ip) { + my $chain =3D ''; + my $in =3D '-'; my $out =3D '-'; + my $srcaddr =3D ''; my $dstaddr =3D ''; + my $protostr =3D ''; + my $srcport =3D ''; my $dstport =3D ''; + + # If ipv6 uses bridge, the use PHYSIN, otherwise use IN + if ($_ =3D~ /(^.* ..:..:..) [\w\-]+ kernel:(.*)(IN=3D.*)(PHYS= IN=3D.*)$/) {} + elsif ($_ =3D~ /(^.* ..:..:..) [\w\-]+ kernel:(.*)(IN=3D.*)$/) {} + my $timestamp =3D $1; my $chain =3D $2; my $packet =3D $3; + $timestamp =3D~ /(...) (..) (..:..:..)/; + my $month =3D $1; my $day =3D $2; my $time =3D $3; + + # If ipv6 uses bridge, the use PHYSIN and PHYSOUT, otherwise use= IN and OUT + if ($a =3D~ /PHYSIN=3D(\w+)/) { $iface =3D $1; } elsif ($a =3D~= /IN=3D(\w+)/) { $iface =3D $1; } + if ($a =3D~ /PHYSOUT=3D(\w+)/) { $out =3D $1; } elsif ($a =3D~= /OUT=3D(\w+)/) { $out =3D $1; } + # Detect ipv4 and ipv6 addresses + if (($a =3D~ /SRC\=3D(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($a = =3D~ /SRC\=3D(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { $srcaddr = =3D $1; } + if (($a =3D~ /DST\=3D(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($a = =3D~ /DST\=3D(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { $dstaddr = =3D $1; } + if ($a =3D~ /PROTO\=3D(\w+)/) { $protostr =3D $1; } + my $protostrlc =3D lc($protostr); + if ($a =3D~ /SPT\=3D([\d\.]+)/){ $srcport =3D $1; } + if ($a =3D~ /DPT\=3D([\d\.]+)/){ $dstport =3D $1; } + + if ($lines % 2) { + print "\n"; + } + else { + print "\n"; + } + print <$time + $chain + $iface + $protostr + + + +
$srcaddr
+ + $srcport + + + +
$dstaddr
+ + $dstport + END - ; - $lines++; - } - } + ; + $lines++; + } + } } print < - + print < + END -; + ; -print ""; -if ($prev !=3D -1) { - print "$Lang::tr{'older'}"; } -else { - print "$Lang::tr{'older'}"; } -print "\n"; + print ""; + if ($prev !=3D -1) { + print "$Lang::tr{'older'}"; + } + else { + print "$Lang::tr{'older'}"; + } + print "\n"; -print ""; -if ($next !=3D -1) { - print "$Lang::tr{'newer'}"; } -else { - print "$Lang::tr{'newer'}"; } -print "\n"; + print ""; + if ($next !=3D -1) { + print "$Lang::tr{'newer'}"; + } + else { + print "$Lang::tr{'newer'}"; + } + print "\n"; -print < - + print < + END -; + ; } diff --git a/html/cgi-bin/logs.cgi/showrequestfromport.dat b/html/cgi-bin/log= s.cgi/showrequestfromport.dat index 6f5f63b..e1f00ae 100644 --- a/html/cgi-bin/logs.cgi/showrequestfromport.dat +++ b/html/cgi-bin/logs.cgi/showrequestfromport.dat @@ -73,60 +73,60 @@ if (!($cgiparams{'MONTH'} =3D~ /^(0|1|2|3|4|5|6|7|8|9|10|= 11)$/) || } elsif($cgiparams{'ACTION'} eq '>>') { - my @temp_then=3D(); - my @temp_now =3D localtime(time); - $temp_now[4] =3D $cgiparams{'MONTH'}; - $temp_now[3] =3D $cgiparams{'DAY'}; - @temp_then =3D localtime(POSIX::mktime(@temp_now) + 86400); - ## Retrieve the same time on the next day - - ## 86400 seconds in a day - $cgiparams{'MONTH'} =3D $temp_then[4]; - $cgiparams{'DAY'} =3D $temp_then[3]; + my @temp_then=3D(); + my @temp_now =3D localtime(time); + $temp_now[4] =3D $cgiparams{'MONTH'}; + $temp_now[3] =3D $cgiparams{'DAY'}; + @temp_then =3D localtime(POSIX::mktime(@temp_now) + 86400); + ## Retrieve the same time on the next day - + ## 86400 seconds in a day + $cgiparams{'MONTH'} =3D $temp_then[4]; + $cgiparams{'DAY'} =3D $temp_then[3]; } elsif($cgiparams{'ACTION'} eq '<<') { - my @temp_then=3D(); - my @temp_now =3D localtime(time); - $temp_now[4] =3D $cgiparams{'MONTH'}; - $temp_now[3] =3D $cgiparams{'DAY'}; - @temp_then =3D localtime(POSIX::mktime(@temp_now) - 86400); - ## Retrieve the same time on the previous day - - ## 86400 seconds in a day - $cgiparams{'MONTH'} =3D $temp_then[4]; - $cgiparams{'DAY'} =3D $temp_then[3]; + my @temp_then=3D(); + my @temp_now =3D localtime(time); + $temp_now[4] =3D $cgiparams{'MONTH'}; + $temp_now[3] =3D $cgiparams{'DAY'}; + @temp_then =3D localtime(POSIX::mktime(@temp_now) - 86400); + ## Retrieve the same time on the previous day - + ## 86400 seconds in a day + $cgiparams{'MONTH'} =3D $temp_then[4]; + $cgiparams{'DAY'} =3D $temp_then[3]; } if (($cgiparams{'DAY'} ne $now[3]) || ($cgiparams{'MONTH'} ne $now[4])) { - my @then =3D (); - if ( ( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now= [3]) || - ( $cgiparams{'MONTH'} > $now[4] ) ) { - @then =3D localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'= }, $cgiparams{'MONTH'}, $year - 1901 )); - } else { - @then =3D localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'= }, $cgiparams{'MONTH'}, $year - 1900 )); - } - $tdoy =3D $then[7]; - my $lastleap=3D($year-1)%4; - if ($tdoy>$doy) { - if ($lastleap =3D=3D 0 && $tdoy < 60) { - $doy=3D$tdoy+366; - } else { - $doy=3D$doy+365; - } - } + my @then =3D (); + if ( ( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3])= || + ( $cgiparams{'MONTH'} > $now[4] ) ) { + @then =3D localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgip= arams{'MONTH'}, $year - 1901 )); + } else { + @then =3D localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgip= arams{'MONTH'}, $year - 1900 )); + } + $tdoy =3D $then[7]; + my $lastleap=3D($year-1)%4; + if ($tdoy>$doy) { + if ($lastleap =3D=3D 0 && $tdoy < 60) { + $doy=3D$tdoy+366; + } else { + $doy=3D$doy+365; + } + } } my $datediff=3D0; my $dowd=3D0; my $multifile=3D0; if ($tdoy ne $doy) { - $datediff=3Dint(($doy-$tdoy)/7); - $dowd=3D($doy-$tdoy)%7; - if (($dow-$dowd)<1) { - $datediff=3D$datediff+1; - } - if (($dow-$dowd)=3D=3D0) { - $multifile=3D1; - } + $datediff=3Dint(($doy-$tdoy)/7); + $dowd=3D($doy-$tdoy)%7; + if (($dow-$dowd)<1) { + $datediff=3D$datediff+1; + } + if (($dow-$dowd)=3D=3D0) { + $multifile=3D1; + } } my $monthstr =3D $shortmonths[$cgiparams{'MONTH'}]; @@ -142,16 +142,16 @@ else { my $skip=3D0; my $filestr=3D''; if ($datediff=3D=3D0) { - $filestr=3D"/var/log/messages"; + $filestr=3D"/var/log/messages"; } else { $filestr=3D"/var/log/messages.$datediff"; $filestr =3D "$filestr.gz" if -f "$filestr.gz"; } if (!(open (FILE,($filestr =3D~ /.gz$/ ? "gzip -dc $filestr |" : $filestr))= )) { - $errormessage =3D "$Lang::tr{'date not in logs'}: $filestr $Lang::tr= {'could not be opened'}"; - $skip=3D1; - # Note: This is in case the log does not exist for that date + $errormessage =3D "$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'co= uld not be opened'}"; + $skip=3D1; + # Note: This is in case the log does not exist for that date } my $lines =3D 0; my @log=3D(); @@ -159,15 +159,15 @@ my $port =3D $cgiparams{port}; if (!$skip) { - while () - { - if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=3D.*)$/= ) { - if($_ =3D~ /DPT\=3D([\d\.]+)/){ - if($1 eq $port){ - $log[$lines] =3D $_; - $lines++; - } - } + while () + { + if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=3D.*)$/)= { + if($_ =3D~ /DPT\=3D([\d\.]+)/){ + if($1 eq $port){ + $log[$lines] =3D $_; + $lines++; + } + } } } close (FILE); @@ -175,26 +175,26 @@ if (!$skip) $skip=3D0; if ($multifile) { - $datediff=3D$datediff-1; - if ($datediff=3D=3D0) { - $filestr=3D"/var/log/messages"; - } else { - $filestr=3D"/var/log/messages.$datediff"; - $filestr =3D "$filestr.gz" if -f "$filestr.gz"; - } - if (!(open (FILE,($filestr =3D~ /.gz$/ ? "gzip -dc $filestr |" : $fi= lestr)))) { - $errormessage=3D"$Lang::tr{'date not in logs'}: $filestr $La= ng::tr{'could not be opened'}"; - $skip=3D1; - } - if (!$skip) { + $datediff=3D$datediff-1; + if ($datediff=3D=3D0) { + $filestr=3D"/var/log/messages"; + } else { + $filestr=3D"/var/log/messages.$datediff"; + $filestr =3D "$filestr.gz" if -f "$filestr.gz"; + } + if (!(open (FILE,($filestr =3D~ /.gz$/ ? "gzip -dc $filestr |" : $filest= r)))) { + $errormessage=3D"$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'= could not be opened'}"; + $skip=3D1; + } + if (!$skip) { while () { - if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=3D.= *)$/) { - if($_ =3D~ /DPT\=3D([\d\.]+)/){ - if($1 eq $port){ - $log[$lines] =3D $_; - $lines++; - } - } + if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=3D.*= )$/) { + if($_ =3D~ /DPT\=3D([\d\.]+)/){ + if($1 eq $port){ + $log[$lines] =3D $_; + $lines++; + } + } } } close (FILE); @@ -264,7 +264,8 @@ END print "

$Lang::tr{'firewall hits'} $longmonthstr $daystr: $lines"; if ($start =3D=3D -1) { - $start =3D $lines - ${Header::viewsize}; } + $start =3D $lines - ${Header::viewsize}; +} if ($start >=3D $lines - ${Header::viewsize}) { $start =3D $lines - ${Heade= r::viewsize}; }; if ($start < 0) { $start =3D 0; } @@ -298,60 +299,65 @@ if ($logsettings{'LOGVIEW_REVERSE'} eq 'on') { @slice = =3D reverse @slice; } $lines =3D 0; foreach $_ (@slice) { - $a =3D $_; - if($_ =3D~ /DPT\=3D([\d\.]+)/){ - if($1 eq $port){ - my $chain =3D ''; - my $in =3D '-'; my $out =3D '-'; - my $srcaddr =3D ''; my $dstaddr =3D ''; - my $protostr =3D ''; - my $srcport =3D ''; my $dstport =3D ''; - - # If ipv6 uses bridge, the use PHYSIN, otherwise use IN - if ($_ =3D~ /(^.* ..:..:..) [\w\-]+ kernel:(.*)(IN=3D.*)(PHYSIN=3D.*)= $/) {} - elsif ($_ =3D~ /(^.* ..:..:..) [\w\-]+ kernel:(.*)(IN=3D.*)$/) {} - my $timestamp =3D $1; my $chain =3D $2; my $packet =3D $3; - $timestamp =3D~ /(...) (..) (..:..:..)/; - my $month =3D $1; my $day =3D $2; my $time =3D $3; my $iface; - - # If ipv6 uses bridge, the use PHYSIN and PHYSOUT, otherwise use IN = and OUT - if ($a =3D~ /PHYSIN\=3D(\w+)/) { $iface =3D $1; } elsif ($a =3D~ /IN\= =3D(\w+)/) { $iface =3D $1; } - if ($a =3D~ /PHYSOUT\=3D(\w+)/) { $out =3D $1; } elsif ($a =3D~ /O= UT\=3D(\w+)/) { $out =3D $1; } - # Detect ipv4 and ipv6 addresses - if (($a =3D~ /SRC\=3D(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($a =3D~ /SRC\= =3D(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { $srcaddr =3D $1; } - if (($a =3D~ /DST\=3D(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($a =3D~ /DST\= =3D(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { $dstaddr =3D $1; } - if ($a =3D~ /PROTO\=3D(\w+)/) { $protostr =3D $1; } - my $protostrlc =3D lc($protostr); - if ($a =3D~ /SPT\=3D([\d\.]+)/){ $srcport =3D $1; } - if ($a =3D~ /DPT\=3D([\d\.]+)/){ $dstport =3D $1; } - - if ($lines % 2) { - print "\n"; } - else { - print "\n"; } - print <$time - $chain - $iface - $protostr - - - -
$srca= ddr
- - $srcport - - - -
$dsta= ddr
- - $dstport - + $a =3D $_; + if($_ =3D~ /DPT\=3D([\d\.]+)/){ + if($1 eq $port){ + my $chain =3D ''; + my $in =3D '-'; + my $out =3D '-'; + my $srcaddr =3D ''; + my $dstaddr =3D ''; + my $protostr =3D ''; + my $srcport =3D ''; + my $dstport =3D ''; + + # If ipv6 uses bridge, the use PHYSIN, otherwise use IN + if ($_ =3D~ /(^.* ..:..:..) [\w\-]+ kernel:(.*)(IN=3D.*)(PHYS= IN=3D.*)$/) {} + elsif ($_ =3D~ /(^.* ..:..:..) [\w\-]+ kernel:(.*)(IN=3D.*)$/) {} + my $timestamp =3D $1; my $chain =3D $2; my $packet =3D $3; + $timestamp =3D~ /(...) (..) (..:..:..)/; + my $month =3D $1; my $day =3D $2; my $time =3D $3; my $iface; + + # If ipv6 uses bridge, the use PHYSIN and PHYSOUT, otherwise use= IN and OUT + if ($a =3D~ /PHYSIN\=3D(\w+)/) { $iface =3D $1; } elsif ($a =3D= ~ /IN\=3D(\w+)/) { $iface =3D $1; } + if ($a =3D~ /PHYSOUT\=3D(\w+)/) { $out =3D $1; } elsif ($a =3D= ~ /OUT\=3D(\w+)/) { $out =3D $1; } + # Detect ipv4 and ipv6 addresses + if (($a =3D~ /SRC\=3D(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($a = =3D~ /SRC\=3D(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { $srcaddr = =3D $1; } + if (($a =3D~ /DST\=3D(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($a = =3D~ /DST\=3D(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { $dstaddr = =3D $1; } + if ($a =3D~ /PROTO\=3D(\w+)/) { $protostr =3D $1; } + my $protostrlc =3D lc($protostr); + if ($a =3D~ /SPT\=3D([\d\.]+)/){ $srcport =3D $1; } + if ($a =3D~ /DPT\=3D([\d\.]+)/){ $dstport =3D $1; } + + if ($lines % 2) { + print "\n"; + } + else { + print "\n"; + } + print <$time + $chain + $iface + $protostr + + + +
$srcaddr
+ + $srcport + + + +
$dstaddr
+ + $dstport + END - ; - $lines++; - } - } + ; + $lines++; + } + } } print < - + print < + END -; + ; -print ""; -if ($prev !=3D -1) { - print "$Lang::tr{'older'}"; } -else { - print "$Lang::tr{'older'}"; } -print "\n"; + print ""; + if ($prev !=3D -1) { + print "$Lang::tr{'older'}"; + } + else { + print "$Lang::tr{'older'}"; + } + print "\n"; -print ""; -if ($next !=3D -1) { - print "$Lang::tr{'newer'}"; } -else { - print "$Lang::tr{'newer'}"; } -print "\n"; + print ""; + if ($next !=3D -1) { + print "$Lang::tr{'newer'}"; + } + else { + print "$Lang::tr{'newer'}"; + } + print "\n"; -print < - + print < + END -; + ; } --=20 1.9.1 --===============8178056924160052041==--