]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - html/cgi-bin/logs.cgi/firewalllogcountry.dat
Merge remote-tracking branch 'mfischer/python' into next
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / logs.cgi / firewalllogcountry.dat
index 123e85571fd83b86e0fe949bfb16a9c938d40101..29c0842188b8974e1e08b3812e65be2bb18bfa52 100644 (file)
@@ -19,6 +19,7 @@ use Getopt::Std;
 #use CGI::Carp 'fatalsToBrowser';
 
 require '/var/ipfire/general-functions.pl';
+require "${General::swroot}/geoip-functions.pl";
 require "${General::swroot}/lang.pl";
 require "${General::swroot}/header.pl";
 
@@ -283,12 +284,14 @@ END
 &Header::openbox('100%', 'left', 'Firewall Logs');
 print "<p><b>$Lang::tr{'firewall hits'} $longmonthstr $daystr: $lines</b></p>";
 
+my $red_interface = &General::get_red_interface();
 my $linesjc = 0;
 my %tabjc;
 my $gi = Geo::IP::PurePerl->new();
 
 if ($pienumber == -1 || $pienumber > $lines || $sortcolumn == 2) { $pienumber = $lines; };
 $lines = 0;
+
 foreach $_ (@log)
 {
   /^... (..) (..:..:..) [\w\-]+ kernel:(.*)(IN=.*)$/;
@@ -296,7 +299,7 @@ foreach $_ (@log)
   $packet =~ /IN=(\w+)/;       my $iface=$1; if ( $1 =~ /2./ ){ $iface="";}
   $packet =~ /SRC=([\d\.]+)/;  my $srcaddr=$1;
 
-  if($iface eq 'red0') {
+  if($iface eq $red_interface) {
     if($srcaddr ne '') {
       my $ccode = $gi->country_code_by_name($srcaddr);
       if( $ccode eq '') {
@@ -408,17 +411,17 @@ if ($showpie != 2 && $pienumber <= 50 && $pienumber != 0) {
         $mygraph->set( dclrs => [ "$color{'color1'}" , "$color{'color2'}" , "$color{'color3'}" , "$color{'color4'}" , "$color{'color5'}" , "$color{'color6'}" , "$color{'color7'}" , "$color{'color8'}" , "$color{'color9'}" , "$color{'color10'}" ] );
         my $myimage = $mygraph->plot(\@data) or die $mygraph->error;
 
-        my @filenames = glob("/srv/web/ipfire/html/graphs/fwlog-ip*.png");
+        my @filenames = glob("/srv/web/ipfire/html/graphs/fwlog-country*.png");
         unlink(@filenames);
         my $imagerandom = rand(1000000);
-        my $imagename = "/srv/web/ipfire/html/graphs/fwlog-ip$imagerandom.png";
+        my $imagename = "/srv/web/ipfire/html/graphs/fwlog-country$imagerandom.png";
         open(FILE,">$imagename");
         print FILE $myimage->png;
         close(FILE);
         #####################################################
-        print "<table align='center'><tr><td>";
-        print "<img src='/graphs/fwlog-ip$imagerandom.png'>";
-        print "</td></tr></table>";
+        print "<div style='text-align:center;'>";
+        print "<img src='/graphs/fwlog-country$imagerandom.png'>";
+        print "</div>";
 }
 
 print <<END
@@ -445,28 +448,28 @@ for($s=0;$s<$lines;$s++)
   $percent = $value[$s] * 100 / $linesjc;
   $percent = sprintf("%.f", $percent);
   $total = $total + $value[$s];
-  if ( ($color % 10) == 1 ){print "<tr>"; $col="bgcolor='$color{'color1'}'";}
-  if ( ($color % 10) == 2 ){print "<tr>"; $col="bgcolor='$color{'color2'}'";}
-  if ( ($color % 10) == 3 ){print "<tr>"; $col="bgcolor='$color{'color3'}'";}
-  if ( ($color % 10) == 4 ){print "<tr>"; $col="bgcolor='$color{'color4'}'";}
-  if ( ($color % 10) == 5 ){print "<tr>"; $col="bgcolor='$color{'color5'}'";}
-  if ( ($color % 10) == 6 ){print "<tr>"; $col="bgcolor='$color{'color6'}'";}
-  if ( ($color % 10) == 7 ){print "<tr>"; $col="bgcolor='$color{'color7'}'";}
-  if ( ($color % 10) == 8 ){print "<tr>"; $col="bgcolor='$color{'color8'}'";}
-  if ( ($color % 10) == 9 ){print "<tr>"; $col="bgcolor='$color{'color9'}'";}
-  if ( ($color % 10) == 0 ){print "<tr>"; $col="bgcolor='$color{'color10'}'";}
-  
+  my $colorIndex = $color % 10;
+  if($colorIndex == 0) {
+    $colorIndex = 10;
+  }
+  $col="bgcolor='$color{\"color$colorIndex\"}'";
   $color++;
+  print "<tr>";
+
   print "<td align='center' $col><form method='post' action='showrequestfromcountry.dat'><input type='hidden' name='MONTH' value='$cgiparams{'MONTH'}'> <input type='hidden' name='DAY' value='$cgiparams{'DAY'}'> <input type='hidden' name='country' value='$key[$s]'> <input type='submit' value='details'></form></td>";
   if($key[$s] eq 'blue0' || $key[$s] eq 'green0' || $key[$s] eq 'orange0') {
       print "<td align='center' $col>$key[$s]</td>";
   }
   else {
-      if($key[$s] ne 'unknown' ) {
-          my $fcode = lc($key[$s]);
-          print "<td align='center' $col><a href='/cgi-bin/country.cgi#$fcode'><img src='/images/flags/$fcode.png' border='0' align='absmiddle' alt='$key[$s]' title='$key[$s]'></a></td>";}
-      else {
-          print "<td align='center' $col>$key[$s]</td>";
+       my $fcode = lc($key[$s]);
+
+       # Get flag icon for of the country.
+       my $flag_icon = &GeoIP::get_flag_icon($fcode);
+
+       if($flag_icon) {
+               print "<td align='center' $col><a href='/cgi-bin/country.cgi#$fcode'><img src='$flag_icon' border='0' align='absmiddle' alt='$key[$s]' title='$key[$s]'></a></td>";
+       } else {
+               print "<td align='center' $col>$key[$s]</td>";
       }
   }
   print "<td align='center' $col>$value[$s]</td>";
@@ -476,16 +479,12 @@ for($s=0;$s<$lines;$s++)
 
 if($cgiparams{'otherspie'} == 2 ){}
 else{
-if ( ($color % 10) == 1 ){print "<tr>"; $col="bgcolor='$color{'color1'}'";}
-if ( ($color % 10) == 2 ){print "<tr>"; $col="bgcolor='$color{'color2'}'";}
-if ( ($color % 10) == 3 ){print "<tr>"; $col="bgcolor='$color{'color3'}'";}
-if ( ($color % 10) == 4 ){print "<tr>"; $col="bgcolor='$color{'color4'}'";}
-if ( ($color % 10) == 5 ){print "<tr>"; $col="bgcolor='$color{'color5'}'";}
-if ( ($color % 10) == 6 ){print "<tr>"; $col="bgcolor='$color{'color6'}'";}
-if ( ($color % 10) == 7 ){print "<tr>"; $col="bgcolor='$color{'color7'}'";}
-if ( ($color % 10) == 8 ){print "<tr>"; $col="bgcolor='$color{'color8'}'";}
-if ( ($color % 10) == 9 ){print "<tr>"; $col="bgcolor='$color{'color9'}'";}
-if ( ($color % 10) == 0 ){print "<tr>"; $col="bgcolor='$color{'color10'}'";}
+  my $colorIndex = $color % 10;
+  if($colorIndex == 0) {
+    $colorIndex = 10;
+  }
+  $col="bgcolor='$color{\"color$colorIndex\"}'";
+  print "<tr>";
 
 if ( $linesjc ne "0")
 {