]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
Multiple CGI's: Use &GeoIP::get_flag_icon for getting country flags.
authorStefan Schantl <stefan.schantl@ipfire.org>
Sat, 2 May 2015 11:45:50 +0000 (13:45 +0200)
committerStefan Schantl <stefan.schantl@ipfire.org>
Sat, 2 May 2015 11:45:50 +0000 (13:45 +0200)
html/cgi-bin/country.cgi
html/cgi-bin/logs.cgi/firewalllog.dat
html/cgi-bin/logs.cgi/firewalllogcountry.dat
html/cgi-bin/logs.cgi/firewalllogip.dat

index 65ce154337f9f5f635005aa7b1e21cb90acf36a3..60c2e5869e260b89d2f37f1c98a90892ff6d9822 100644 (file)
@@ -31,6 +31,7 @@ my @flaglistfiles=();
 my $flag = '';
 
 require '/var/ipfire/general-functions.pl';
+require "${General::swroot}/geoip-functions.pl";
 require "${General::swroot}/lang.pl";
 require "${General::swroot}/header.pl";
 
@@ -64,12 +65,16 @@ foreach $flag (@flaglistfiles)
 
        my $flagcode = uc(substr($flag, 0, 2));
        my $fcode = lc($flagcode);
+
+       # Get flag icon for of the country.
+       my $flag_icon = &GeoIP::get_flag_icon($fcode);
+
        my $country = Locale::Country::code2country($fcode);
        if($fcode eq 'eu') { $country = 'Europe'; }
        if($fcode eq 'tp') { $country = 'East Timor'; }
        if($fcode eq 'yu') { $country = 'Yugoslavia'; }
        if ($lines % 2) {
-               print "<td $col><a id='$fcode'><img src='/images/flags/$fcode.png' alt='$flagcode' title='$flagcode'/></a></td>";
+               print "<td $col><a id='$fcode'><img src='$flag_icon' alt='$flagcode' title='$flagcode'/></a></td>";
                print "<td $col>$flagcode</td>";
                print "<td $col>$country</td></tr>\n";
        }
@@ -81,7 +86,7 @@ foreach $flag (@flaglistfiles)
                        $col="style='background-color:${Header::table1colour};'";
                }
                print "<tr>";
-               print "<td $col><a id='$fcode'><img src='/images/flags/$fcode.png' alt='$flagcode' title='$flagcode'/></a></td>";
+               print "<td $col><a id='$fcode'><img src='$flag_icon' alt='$flagcode' title='$flagcode'/></a></td>";
                print "<td $col>$flagcode</td>";
                print "<td $col>$country</td>";
                print "<td $col>&nbsp;</td>";
index 7525626668b6aa595b1a6dca0221a385032210b4..5a584d60debb6bdcd9709ea0525ca273e4db4bdc 100644 (file)
@@ -21,6 +21,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";
 
@@ -372,10 +373,15 @@ foreach $_ (@log)
         <td align='center' $col>$srcport<br/>$dstport</td>
 END
 ;
-        if ( $fcode ne "" ){
-        print "<td align='center' $col><a href='../country.cgi#$fcode'><img src='/images/flags/$fcode.png' border='0' align='absmiddle' alt='$ccode'></a></td>";}
-        else {
-        print "<td align='center' $col></td>";}
+       # 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='../country.cgi#$fcode'><img src='$flag_icon' border='0' align='absmiddle' alt='$ccode'></a></td>";
+       } else {
+               print "<td align='center' $col></td>";
+       }
+
         print <<END
         <td align='center' $col>$macaddr</td>
 </tr>
index 3a774f92298f198b50ebf82c61b81a83967cd75e..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";
 
@@ -460,11 +461,15 @@ for($s=0;$s<$lines;$s++)
       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>";
index 07bcc77f813bdfd2ed17988103c717584dd37c23..7d82d20e725e07f3569921a51ef030650b5e2510 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";
 
@@ -441,13 +442,19 @@ for($s=0;$s<$lines;$s++)
   $color++;
   print "<td align='center' $col><form method='post' action='showrequestfromip.dat'><input type='hidden' name='MONTH' value='$cgiparams{'MONTH'}'> <input type='hidden' name='DAY' value='$cgiparams{'DAY'}'> <input type='hidden' name='ip' value='$key[$s]'> <input type='submit' value='$Lang::tr{'details'}'></form></td>";
   print "<td align='center' $col><a href='/cgi-bin/ipinfo.cgi?ip=$key[$s]'>$key[$s]</a></td>";
-  if ( $fcode ne "" ){
-    print "<td align='center' $col><a href='/cgi-bin/country.cgi#$fcode'><img src='/images/flags/$fcode.png' border='0' align='absmiddle' alt='$ccode' title='$ccode'></a></td>";}
-  else {
-    print "<td align='center' $col></td>";}
-    print "<td align='center' $col>$value[$s]</td>";
-    print "<td align='center' $col>$percent</td>";
-    print "</tr>";
+
+  # Get flag icon for of the country.
+  my $flag_icon = &GeoIP::get_flag_icon($ccode);
+
+  if ( $flag_icon ) {
+       print "<td align='center' $col><a href='/cgi-bin/country.cgi#$fcode'><img src='$flag_icon' border='0' align='absmiddle' alt='$ccode' title='$ccode'></a></td>";
+  } else {
+       print "<td align='center' $col></td>";
+  }
+
+  print "<td align='center' $col>$value[$s]</td>";
+  print "<td align='center' $col>$percent</td>";
+  print "</tr>";
   }
 
 if($cgiparams{'otherspie'} == 2 ){}