#
# This code is distributed under the terms of the GPL
#
-# JC HERITIER
+# JC HERITIER
# page inspired from the initial firewalllog.dat
#
# Modified for IPFire by Christian Schmidt (www.ipfire.org)
#use CGI::Carp 'fatalsToBrowser';
#use strict;
-use Geo::IP::PurePerl;
require '/var/ipfire/general-functions.pl';
+require "${General::swroot}/location-functions.pl";
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
my $lines = 0;
my @log=();
my $country = $cgiparams{country};
-my $gi = Geo::IP::PurePerl->new();
if (!$skip)
{
if ($packet =~ /PHYSIN=(\w+)/) { $iface = $1; } elsif ($packet =~ /IN=(\w+)/) { $iface = $1; }
# Extract ipv4 and ipv6 addresses
if (($packet =~ /SRC\=(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($packet =~ /SRC\=(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) {
- $srcaddr = $1;
+ $srcaddr = $1;
}
if($iface eq $country) {
}
elsif($srcaddr ne '') {
# or srcaddr matches country code
- my $ccode = $gi->country_code_by_name($srcaddr);
+ my $ccode = &Location::Functions::lookup_country_code($srcaddr);
if($ccode eq uc($country)){
$log[$lines] = $_;
$lines++;
}
}
}
- close (FILE);
+ close (FILE);
}
$skip=0;
# extract ipv4 and ipv6 address
elsif (($_ =~ /SRC\=(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($_ =~ /SRC\=(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) {
my $srcaddr=$1;
- my $ccode = $gi->country_code_by_name($srcaddr);
+ my $ccode = &Location::Functions::lookup_country_code($srcaddr);
if($ccode eq uc($country)){
# or srcaddr matches country code
$log[$lines] = $_;
}
&Header::showhttpheaders();
-&Header::openpage($Lang::tr{'firewall log'}, 1, '');
+&Header::openpage($Lang::tr{'firewall log country'}, 1, '');
&Header::openbigbox('100%', 'left', '', $errormessage);
if ($errormessage) {
{
print "\t<option ";
if ($month == $cgiparams{'MONTH'}) {
- print "selected='selected' ";
+ print "selected='selected' ";
}
print "value='$month'>$longmonths[$month]</option>\n";
}
<select name='DAY'>
END
;
-for ($day = 1; $day <= 31; $day++)
+for ($day = 1; $day <= 31; $day++)
{
print "\t<option ";
if ($day == $cgiparams{'DAY'}) {
&Header::closebox();
-&Header::openbox('100%', 'left', $Lang::tr{'firewall log'});
+&Header::openbox('100%', 'left', $Lang::tr{'firewall log country'});
print "<p><b>$Lang::tr{'firewall hits'} $longmonthstr $daystr: $lines</b></p>";
if ($start == -1) {
- $start = $lines - ${Header::viewsize};
+ $start = $lines - ${Header::viewsize};
}
if ($start >= $lines - ${Header::viewsize}) { $start = $lines - ${Header::viewsize}; };
if ($start < 0) { $start = 0; }
if (/^... (..) (..:..:..) [\w\-]+ kernel:(.*)(PHYSIN=.*)$/) {}
elsif (/^... (..) (..:..:..) [\w\-]+ kernel:(.*)(IN=.*)$/) {};
my $packet = $4;
- my $iface = '';
+ my $iface = '';
# If ipv6 uses bridge, use PHYSIN otherwise use IN
- if ($packet =~ /PHYSIN=(\w+)/) { $iface = $1; } elsif ($packet =~ /IN=(\w+)/) { $iface = $1; }
+ if ($packet =~ /PHYSIN=(\w+)/) { $iface = $1; } elsif ($packet =~ /IN=(\w+)/) { $iface = $1; }
if ( $1 =~ /2./ ){ $iface=""; }
my $srcaddr = '';
# Extract ipv4 and ipv6 addresses
if($iface eq $country || $srcaddr ne '') {
my $ccode='';
if($iface ne $country) {
- $ccode = $gi->country_code_by_name($srcaddr);
+ $ccode = &Location::Functions::lookup_country_code($srcaddr);
}
if($iface eq $country || $ccode eq uc($country)) {
my $chain = '';
if ($a =~ /DPT\=([\d\.]+)/){ $dstport = $1; }
if ($lines % 2) {
- print "<tr bgcolor='${Header::table1colour}'>\n";
+ print "<tr bgcolor='${Header::table1colour}'>\n";
}
else {
- print "<tr bgcolor='${Header::table2colour}'>\n";
+ print "<tr bgcolor='${Header::table2colour}'>\n";
}
print <<END
<td align='center'>$time</td>
&oldernewer();
+ print"<table width='100%'><tr><td align='center'><a href='/cgi-bin/logs.cgi/firewalllogcountry.dat'><img src='/images/back.png' alt='$Lang::tr{'back'}' title='$Lang::tr{'back'}' /></a></td></tr></table>";
+
&Header::closebox();
&Header::closebigbox();
print "<td align='center' width='50%'>";
if ($prev != -1) {
- print "<a href='/cgi-bin/logs.cgi/showrequestfromcountry.dat?$prev,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{country}'>$Lang::tr{'older'}</a>";
+ print "<a href='/cgi-bin/logs.cgi/showrequestfromcountry.dat?$prev,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{country}'>$Lang::tr{'older'}</a>";
}
else {
- print "$Lang::tr{'older'}";
+ print "$Lang::tr{'older'}";
}
print "</td>\n";
print "<td align='center' width='50%'>";
if ($next != -1) {
- print "<a href='/cgi-bin/logs.cgi/showrequestfromcountry.dat?$next,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{country}'>$Lang::tr{'newer'}</a>";
+ print "<a href='/cgi-bin/logs.cgi/showrequestfromcountry.dat?$next,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{country}'>$Lang::tr{'newer'}</a>";
}
else {
- print "$Lang::tr{'newer'}";
+ print "$Lang::tr{'newer'}";
}
print "</td>\n";