]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blobdiff - html/cgi-bin/logs.cgi/firewalllogport.dat
firewalllogs*.dat: Reduce amount of code to set row bgcolor
[people/teissler/ipfire-2.x.git] / html / cgi-bin / logs.cgi / firewalllogport.dat
index 21b1ffadc9410afff7ddf40f476e1887e91e5376..9f7ce3a11375e1fe1ab67e557e18789062503f27 100644 (file)
@@ -13,8 +13,8 @@
 use strict;
 
 # 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";
@@ -222,7 +222,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'}'>
@@ -267,15 +267,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="center">$Lang::tr{'Number of Ports 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 Ports 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
 ;
 
@@ -324,7 +324,7 @@ else
         @tabjc2 = sort { $a <=> $b } keys (%tabjc);
 }
 
-my $colour=1;
+my $color=10;
 
 
 
@@ -374,13 +374,11 @@ else{
 
 my @data = (\@ports,\@numb);
 use GD::Graph::colour qw( :files );
-my %colours = ();
-my %mainsettings = ();
-&General::readhash("${General::swroot}/main/settings", \%mainsettings);
-my %colours = ();
+
+my %color = ();
 my %mainsettings = ();
 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
-&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colours.txt", \%colours);
+&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
 
 if ($showpie != 2 && $pienumber <= 50 && $pienumber != 0) {
         my $mygraph = GD::Graph::pie->new(500, 350);
@@ -391,7 +389,7 @@ if ($showpie != 2 && $pienumber <= 50 && $pienumber != 0) {
              ) or warn $mygraph->error;
 
         $mygraph->set_value_font(GD::gdMediumBoldFont);
-        $mygraph->set( dclrs => [ "$colours{'colour1'}" , "$colours{'colour2'}" , "$colours{'colour3'}" , "$colours{'colour4'}" , "$colours{'colour5'}" , "$colours{'colour6'}" , "$colours{'colour7'}" , "$colours{'colour8'}" , "$colours{'colour9'}" , "$colours{'colour10'}" ] );
+        $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-port*.png");
@@ -408,13 +406,13 @@ if ($showpie != 2 && $pienumber <= 50 && $pienumber != 0) {
 }
 
 print <<END
-<TABLE WIDTH='100%'>
-<TR>
-<TD WIDTH='10%' ALIGN='CENTER' CLASS='boldbase'></TD>
-<TD WIDTH='33%' ALIGN='CENTER' CLASS='boldbase'><B>Port</B></TD>
-<TD WIDTH='33%' ALIGN='CENTER' CLASS='boldbase'><B>Count</B></TD>
-<TD WIDTH='33%' 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='33%' align='center' class='boldbase'><b>$Lang::tr{'port'}</b></th>
+<th width='33%' align='center' class='boldbase'><b>count</b></th>
+<th width='33%' align='center' class='boldbase'><b>$Lang::tr{'percentage'}</b></th>
+</tr>
 END
 ;
 
@@ -423,59 +421,56 @@ my $show=0;
 
 my $s;
 my $percent;
+my $col="";
+
 for($s=0;$s<$lines;$s++)
 {
   $show++;
   $percent = $value[$s] * 100 / $linesjc;
   $percent = sprintf("%.f", $percent);
   $total = $total + $value[$s];
-  if ( ($colour % 10) == 1 ){print "<TR BGCOLOR='$colours{'colour1'}'>\n";}
-  if ( ($colour % 10) == 2 ){print "<TR BGCOLOR='$colours{'colour2'}'>\n";}
-  if ( ($colour % 10) == 3 ){print "<TR BGCOLOR='$colours{'colour3'}'>\n";}
-  if ( ($colour % 10) == 4 ){print "<TR BGCOLOR='$colours{'colour4'}'>\n";}
-  if ( ($colour % 10) == 5 ){print "<TR BGCOLOR='$colours{'colour5'}'>\n";}
-  if ( ($colour % 10) == 6 ){print "<TR BGCOLOR='$colours{'colour6'}'>\n";}
-  if ( ($colour % 10) == 7 ){print "<TR BGCOLOR='$colours{'colour7'}'>\n";}
-  if ( ($colour % 10) == 8 ){print "<TR BGCOLOR='$colours{'colour8'}'>\n";}
-  if ( ($colour % 10) == 9 ){print "<TR BGCOLOR='$colours{'colour9'}'>\n";}
-  if ( ($colour % 10) == 0 ){print "<TR BGCOLOR='$colours{'colour10'}'>\n";}
-
-  $colour++;
-  print "<TD ALIGN='CENTER'><form method='post' action='showrequestfromport.dat'><input type='hidden' name='MONTH' value='$cgiparams{'MONTH'}'> <input type='hidden' name='DAY' value='$cgiparams{'DAY'}'> <input type='hidden' name='port' value='$key[$s]'> <input type='submit' value='details'></form></TD>";
-  print "<TD ALIGN='CENTER'>$key[$s]</TD>";
-  print "<TD ALIGN='CENTER'>$value[$s]</TD>";
-  print "<TD ALIGN='CENTER'>$percent</TD>";
-  print "</TR>";
+  my $colorIndex = $color % 10;
+  if($colorIndex == 0) {
+    $colorIndex = 10;
+  }
+  $col="bgcolor='$color{\"color$colorIndex\"}'";
+  print "<tr>";
+
+  $color++;
+  print "<td align='center' $col><form method='post' action='showrequestfromport.dat'><input type='hidden' name='MONTH' value='$cgiparams{'MONTH'}'> <input type='hidden' name='DAY' value='$cgiparams{'DAY'}'> <input type='hidden' name='port' value='$key[$s]'> <input type='submit' value='details'></form></td>";
+  print "<td align='center' $col>$key[$s]</td>";
+  print "<td align='center' $col>$value[$s]</td>";
+  print "<td align='center' $col>$percent</td>";
+  print "</tr>";
 }
 
 if($cgiparams{'otherspie'} == 2 ){}
 else{
-if ( ($colour % 10) == 1 ){print "<TR BGCOLOR='$colours{'colour1'}'>\n";}
-if ( ($colour % 10) == 2 ){print "<TR BGCOLOR='$colours{'colour2'}'>\n";}
-if ( ($colour % 10) == 3 ){print "<TR BGCOLOR='$colours{'colour3'}'>\n";}
-if ( ($colour % 10) == 4 ){print "<TR BGCOLOR='$colours{'colour4'}'>\n";}
-if ( ($colour % 10) == 5 ){print "<TR BGCOLOR='$colours{'colour5'}'>\n";}
-if ( ($colour % 10) == 6 ){print "<TR BGCOLOR='$colours{'colour6'}'>\n";}
-if ( ($colour % 10) == 7 ){print "<TR BGCOLOR='$colours{'colour7'}'>\n";}
-if ( ($colour % 10) == 8 ){print "<TR BGCOLOR='$colours{'colour8'}'>\n";}
-if ( ($colour % 10) == 9 ){print "<TR BGCOLOR='$colours{'colour9'}'>\n";}
-if ( ($colour % 10) == 0 ){print "<TR BGCOLOR='$colours{'colour10'}'>\n";}
+  my $colorIndex = $color % 10;
+  if($colorIndex == 0) {
+    $colorIndex = 10;
+  }
+  $col="bgcolor='$color{\"color$colorIndex\"}'";
+  print "<tr>";
 
+if ( $linesjc ne "0")
+{
 my $dif;
 $dif = $linesjc - $total;
 $percent = $dif * 100 / $linesjc;
 $percent = sprintf("%.f", $percent);
 print <<END
-<TD ALIGN='CENTER'></TD>
-<TD ALIGN='CENTER'>$Lang::tr{'otherport'}</TD>
-<TD ALIGN='CENTER'>$dif</TD>
-<TD ALIGN='CENTER'>$percent</TD> 
-</TR>
+<td align='center' $col></td>
+<td align='center' $col>$Lang::tr{'otherport'}</td>
+<td align='center' $col>$dif</td>
+<td align='center' $col>$percent</td>
+</tr>
 END
 ;
 }
+}
 print <<END
-</TABLE>
+</table>
 END
 ;
 
@@ -484,6 +479,7 @@ END
 &Header::closepage();
 
 sub findkey {
+  my $v;
   foreach $v (@keytabjc) {
     if ($tabjc{$v} eq $_[0]) {
       delete $tabjc{$v};
@@ -494,7 +490,9 @@ sub findkey {
     }
   }
 }
+
 sub checkversion {
-        #Automatic Updates is disabled
-        return "0","0";
-        }
+    #Automatic Updates is disabled
+    return "0","0";
+}
+