]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blobdiff - html/cgi-bin/logs.cgi/firewalllogip.dat
firewalllogs*.dat: Reduce amount of code to set row bgcolor
[people/teissler/ipfire-2.x.git] / html / cgi-bin / logs.cgi / firewalllogip.dat
index b3f5535191d480cf325281f74b246975fd1bc01a..e4e845198be965c6399e246d45aaa5124d5a1e81 100644 (file)
@@ -15,8 +15,8 @@ use Geo::IP::PurePerl;
 use Getopt::Std;
 
 # enable only the following on debugging purpose
-use warnings;
-use CGI::Carp 'fatalsToBrowser';
+#use warnings;
+#use CGI::Carp 'fatalsToBrowser';
 
 require '/var/ipfire/general-functions.pl';
 require "${General::swroot}/lang.pl";
@@ -24,10 +24,6 @@ require "${General::swroot}/header.pl";
 
 use POSIX();
 
-#workaround to suppress a warning when a variable is used only once
-my @dummy = ( ${Header::table2colour} );
-undef (@dummy);
-
 my %cgiparams=();
 my %settings=();
 my $pienumber;
@@ -225,7 +221,7 @@ if ($errormessage) {
         &Header::closebox();
 }
 
-&Header::openbox('100%', 'left', "$Lang::tr{'settings'}:");
+&Header::openbox('100%', 'left', "$Lang::tr{'settings'}");
 
 print <<END
 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
@@ -270,15 +266,15 @@ print <<END
 </td>
 <td width='5%'  align='center'><input type='submit' name='ACTION' title='$Lang::tr{'day before'}' value='&lt;&lt;' /></td>
 <td width='5%'  align='center'><input type='submit' name='ACTION' title='$Lang::tr{'day after'}' value='&gt;&gt;' /></td>
-<td width='20%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'update'}' /></td>
+<td width='20%' align='right'><input type='submit' name='ACTION' value='$Lang::tr{'update'}' /></td>
+</tr>
+<tr>
+       <td colspan='3' align='left' valign="left">$Lang::tr{'Number of IPs for the pie chart'}:</td>
+       <td colspan='3' align='left' valign="center"><input type='text' name='pienumber' value='$pienumber' size='4'></td>
+       <td align='right'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
 </tr>
 </table>
-<table width='100%'>
-<tr><td width='20%' align='right' valign="center">$Lang::tr{'Number of IPs for the pie chart'}:</td>
-          <td width='10%' align='left' valign="center"><input type='text' name='pienumber' value='$pienumber' size='4'></td>
-          <td width='20%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td></tr>
-       </table>
-       </form>
+</form>
 END
 ;
 
@@ -407,14 +403,14 @@ if ($showpie != 2 && $pienumber <= 50 && $pienumber != 0) {
 }
 
 print <<END
-<TABLE WIDTH='100%'>
-<TR>
-<TD WIDTH='10%' ALIGN='CENTER' CLASS='boldbase'></TD>
-<TD WIDTH='30%' ALIGN='CENTER' CLASS='boldbase'><B>IP</B></TD>
-<TD WIDTH='10%' ALIGN='CENTER' CLASS='boldbase'><B>Flag</B></TD>
-<TD WIDTH='10%' ALIGN='CENTER' CLASS='boldbase'><B>Count</B></TD>
-<TD WIDTH='30%' ALIGN='CENTER' CLASS='boldbase'><B>Percent</B></TD>
-</TR>
+<table width='100%' class='tbl'>
+<tr>
+<th width='10%' align='center' class='boldbase'></th>
+<th width='30%' align='center' class='boldbase'><b>$Lang::tr{'ip address'}</b></th>
+<th width='10%' align='center' class='boldbase'><b>$Lang::tr{'country'}</b></th>
+<th width='10%' align='center' class='boldbase'><b>Count</b></th>
+<th width='30%' align='center' class='boldbase'><b>$Lang::tr{'percentage'}</b></th>
+</tr>
 END
 ;
 
@@ -423,6 +419,7 @@ my $show=0;
 
 my $s;
 my $percent;
+my $col="";
 
 for($s=0;$s<$lines;$s++)
 {
@@ -430,42 +427,37 @@ 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 BGCOLOR='$color{'color1'}'>\n";}
-  if ( ($color % 10) == 2 ){print "<TR BGCOLOR='$color{'color2'}'>\n";}
-  if ( ($color % 10) == 3 ){print "<TR BGCOLOR='$color{'color3'}'>\n";}
-  if ( ($color % 10) == 4 ){print "<TR BGCOLOR='$color{'color4'}'>\n";}
-  if ( ($color % 10) == 5 ){print "<TR BGCOLOR='$color{'color5'}'>\n";}
-  if ( ($color % 10) == 6 ){print "<TR BGCOLOR='$color{'color6'}'>\n";}
-  if ( ($color % 10) == 7 ){print "<TR BGCOLOR='$color{'color7'}'>\n";}
-  if ( ($color % 10) == 8 ){print "<TR BGCOLOR='$color{'color8'}'>\n";}
-  if ( ($color % 10) == 9 ){print "<TR BGCOLOR='$color{'color9'}'>\n";}
-  if ( ($color % 10) == 0 ){print "<TR BGCOLOR='$color{'color10'}'>\n";}
+  my $colorIndex = $color % 10;
+  if($colorIndex == 0) {
+    $colorIndex = 10;
+  }
+  $col="bgcolor='$color{\"color$colorIndex\"}'";
+  print "<tr>";
   
   my $gi = Geo::IP::PurePerl->new();
   my $ccode = $gi->country_code_by_name($key[$s]);
   my $fcode = lc($ccode);
   
   $color++;
-  print "<TD ALIGN='CENTER'><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='details'></form></TD>";
-  print "<TD ALIGN='CENTER'><a href='/cgi-bin/ipinfo.cgi?ip=$key[$s]'>$key[$s]</a></TD>";
-  print "<TD ALIGN='CENTER'><a href='/cgi-bin/country.cgi#$fcode'><img src='/images/flags/$fcode.png' border='0' align='absmiddle' alt='$ccode'></a></TD>";
-  print "<TD ALIGN='CENTER'>$value[$s]</TD>";
-  print "<TD ALIGN='CENTER'>$percent</TD>";
-  print "</TR>";
-}
+  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='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'></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 ){}
 else{
-if ( ($color % 10) == 1 ){print "<TR BGCOLOR='$color{'color1'}'>\n";}
-if ( ($color % 10) == 2 ){print "<TR BGCOLOR='$color{'color2'}'>\n";}
-if ( ($color % 10) == 3 ){print "<TR BGCOLOR='$color{'color3'}'>\n";}
-if ( ($color % 10) == 4 ){print "<TR BGCOLOR='$color{'color4'}'>\n";}
-if ( ($color % 10) == 5 ){print "<TR BGCOLOR='$color{'color5'}'>\n";}
-if ( ($color % 10) == 6 ){print "<TR BGCOLOR='$color{'color6'}'>\n";}
-if ( ($color % 10) == 7 ){print "<TR BGCOLOR='$color{'color7'}'>\n";}
-if ( ($color % 10) == 8 ){print "<TR BGCOLOR='$color{'color8'}'>\n";}
-if ( ($color % 10) == 9 ){print "<TR BGCOLOR='$color{'color9'}'>\n";}
-if ( ($color % 10) == 0 ){print "<TR BGCOLOR='$color{'color10'}'>\n";}
+  my $colorIndex = $color % 10;
+  if($colorIndex == 0) {
+    $colorIndex = 10;
+  }
+  $col="bgcolor='$color{\"color$colorIndex\"}'";
+  print "<tr>";
 
 if ( $linesjc ne "0")
 {
@@ -474,18 +466,18 @@ $dif = $linesjc - $total;
 $percent = $dif * 100 / $linesjc;
 $percent = sprintf("%.f", $percent);
 print <<END
-<TD ALIGN='CENTER'></TD>
-<TD ALIGN='CENTER'>$Lang::tr{'otherip'}</TD>
-<TD ALIGN='CENTER'></TD>
-<TD ALIGN='CENTER'>$dif</TD>
-<TD ALIGN='CENTER'>$percent</TD> 
-</TR>
+<td align='center' $col></td>
+<td align='center' $col>$Lang::tr{'otherip'}</td>
+<td align='center' $col></td>
+<td align='center' $col>$dif</td>
+<td align='center' $col>$percent</td>
+</tr>
 END
 ;
 }
 }
 print <<END
-</TABLE>
+</table>
 END
 ;
 
@@ -504,7 +496,10 @@ sub findkey {
       last;
     }
   }
-}sub checkversion {
-        #Automatic Updates is disabled
-        return "0","0";
-        }
+}
+
+sub checkversion {
+    #Automatic Updates is disabled
+    return "0","0";
+}
+