From: Alf Høgemark Date: Mon, 17 Feb 2014 19:05:00 +0000 (+0100) Subject: showrequestfromcountry.dat: Use language string, and fix links X-Git-Url: http://git.ipfire.org/?p=people%2Fteissler%2Fipfire-2.x.git;a=commitdiff_plain;h=bde7a7d296b2d0ab165687d9c46dcf67caf955a1 showrequestfromcountry.dat: Use language string, and fix links Define language key for input field. Fix links for older and newer links. Indentation fixes. The code is a copy from showrequestfromip.dat, ideally we should have merged all three showrequestfrom*.dat files into one file, but I do not do that now, because it would really require a rewrite of most of the logic, and I understand that one does not want to do such changes in 2.x. --- diff --git a/html/cgi-bin/logs.cgi/showrequestfromcountry.dat b/html/cgi-bin/logs.cgi/showrequestfromcountry.dat index 25a9f1578..c84211618 100644 --- a/html/cgi-bin/logs.cgi/showrequestfromcountry.dat +++ b/html/cgi-bin/logs.cgi/showrequestfromcountry.dat @@ -58,7 +58,7 @@ if ($ENV{'QUERY_STRING'} && $cgiparams{'ACTION'} ne $Lang::tr{'update'}) $start = $temp[0]; $cgiparams{'MONTH'} = $temp[1]; $cgiparams{'DAY'} = $temp[2]; - $cgiparams{ip} = $temp[3]; + $cgiparams{country} = $temp[3]; } if (!($cgiparams{'MONTH'} =~ /^(0|1|2|3|4|5|6|7|8|9|10|11)$/) || @@ -156,8 +156,8 @@ my $gi = Geo::IP::PurePerl->new(); if (!$skip) { - while () - { + while () + { if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=.*)$/) { if($_ =~ /SRC\=([\d\.]+)/){ my $srcaddr=$1; @@ -252,7 +252,7 @@ print < -$Lang::tr{'source ip'} +$Lang::tr{'source ip country'} @@ -279,17 +279,17 @@ if ($start == 0) { $prev = -1; } if ($lines != 0) { &oldernewer(); } print < - -$Lang::tr{'time'} -$Lang::tr{'chain'} -$Lang::tr{'iface'} -$Lang::tr{'proto'} -$Lang::tr{'source'} -$Lang::tr{'src port'} -$Lang::tr{'destination'} -$Lang::tr{'dst port'} - + + + + + + + + + + + END ; @@ -305,57 +305,57 @@ foreach $_ (@slice) my $srcaddr=$1; my $ccode = $gi->country_code_by_name($srcaddr); if($ccode eq $country){ - my $chain = ''; - my $in = '-'; my $out = '-'; - my $srcaddr = ''; my $dstaddr = ''; - my $protostr = ''; - my $srcport = ''; my $dstport = ''; - - $_ =~ /(^.* ..:..:..) [\w\-]+ kernel:(.*)(IN=.*)$/; - my $timestamp = $1; my $chain = $2; my $packet = $3; - $timestamp =~ /(...) (..) (..:..:..)/; - my $month = $1; my $day = $2; my $time = $3; - - if ($a =~ /IN\=(\w+)/) { $iface = $1; } - if ($a =~ /OUT\=(\w+)/) { $out = $1; } - if ($a =~ /SRC\=([\d\.]+)/) { $srcaddr = $1; } - if ($a =~ /DST\=([\d\.]+)/) { $dstaddr = $1; } - if ($a =~ /PROTO\=(\w+)/) { $protostr = $1; } - my $protostrlc = lc($protostr); - if ($a =~ /SPT\=([\d\.]+)/){ $srcport = $1; } - if ($a =~ /DPT\=([\d\.]+)/){ $dstport = $1; } - - if ($lines % 2) { - print "\n"; } - else { - print "\n"; } - print <$time - - - - - - - - + my $chain = ''; + my $in = '-'; my $out = '-'; + my $srcaddr = ''; my $dstaddr = ''; + my $protostr = ''; + my $srcport = ''; my $dstport = ''; + + $_ =~ /(^.* ..:..:..) [\w\-]+ kernel:(.*)(IN=.*)$/; + my $timestamp = $1; my $chain = $2; my $packet = $3; + $timestamp =~ /(...) (..) (..:..:..)/; + my $month = $1; my $day = $2; my $time = $3; + + if ($a =~ /IN\=(\w+)/) { $iface = $1; } + if ($a =~ /OUT\=(\w+)/) { $out = $1; } + if ($a =~ /SRC\=([\d\.]+)/) { $srcaddr = $1; } + if ($a =~ /DST\=([\d\.]+)/) { $dstaddr = $1; } + if ($a =~ /PROTO\=(\w+)/) { $protostr = $1; } + my $protostrlc = lc($protostr); + if ($a =~ /SPT\=([\d\.]+)/){ $srcport = $1; } + if ($a =~ /DPT\=([\d\.]+)/){ $dstport = $1; } + + if ($lines % 2) { + print "\n"; } + else { + print "\n"; } + print <$time + + + + + + + + END ; - $lines++; + $lines++; } } } print < +
$Lang::tr{'time'}$Lang::tr{'chain'}$Lang::tr{'iface'}$Lang::tr{'proto'}$Lang::tr{'source'}$Lang::tr{'src port'}$Lang::tr{'destination'}$Lang::tr{'dst port'}
$chain$iface$protostr - - -
$srcaddr
-
$srcport - - -
$dstaddr
-
$dstport
$chain$iface$protostr + + +
$srcaddr
+
$srcport + + +
$dstaddr
+
$dstport
END ; @@ -369,29 +369,30 @@ END sub oldernewer { -print < - + print < + END ; -print ""; -if ($prev != -1) { - print "$Lang::tr{'older'}"; } -else { - print "$Lang::tr{'older'}"; } -print "\n"; + print ""; + if ($prev != -1) { + print "$Lang::tr{'older'}"; } + else { + print "$Lang::tr{'older'}"; } + print "\n"; -print ""; -if ($next != -1) { - print "$Lang::tr{'newer'}"; } -else { - print "$Lang::tr{'newer'}"; } -print "\n"; + print ""; + if ($next != -1) { + print "$Lang::tr{'newer'}"; } + else { + print "$Lang::tr{'newer'}"; } + print "\n"; print < - + + END ; } + diff --git a/langs/de/cgi-bin/de.pl b/langs/de/cgi-bin/de.pl index 700f41b3b..11e8370a7 100644 --- a/langs/de/cgi-bin/de.pl +++ b/langs/de/cgi-bin/de.pl @@ -1907,6 +1907,7 @@ 'source ip' => 'Quell-IP-Adresse', 'source ip and port' => 'Quell-IP:Port', 'source ip bad' => 'Ungültige Quell-IP-Adresse.', +'source ip country' => 'Quell-IP-Adresse Land', 'source ip in use' => 'Benutzte Quell-IP:', 'source ip or net' => 'Quellen-IP oder Netz', 'source net' => 'Quell-Netz', diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl index 6a7835275..450842880 100644 --- a/langs/en/cgi-bin/en.pl +++ b/langs/en/cgi-bin/en.pl @@ -1942,6 +1942,7 @@ 'source ip' => 'Source IP', 'source ip and port' => 'Source IP: Port', 'source ip bad' => 'Not a valid IP address or a network address.', +'source ip country' => 'Source IP Country', 'source ip in use' => 'Source IP in use:', 'source ip or net' => 'Source IP or Net', 'source net' => 'Source Net',