| $Lang::tr{'month'}: | ++ | +$Lang::tr{'day'}: | ++ | ++ | + | + |
| $Lang::tr{'Number of IPs for the pie chart'}: | ++ |
$Lang::tr{'firewall hits'} $longmonthstr $daystr: $lines
"; + +my $linesjc = 0; +my %tabjc; + +if ($pienumber == -1 || $pienumber > $lines || $sortcolumn == 2) { $pienumber = $lines; }; +$lines = 0; +foreach $_ (@log) +{ + if($_ =~ /SRC\=([\d\.]+)/){ + $tabjc{$1} = $tabjc{$1} + 1 ; + if(($tabjc{$1} == 1) && ($lines < $pienumber)) { $lines = $lines + 1; } + $linesjc++; + } +} + +$pienumber = $lines; + +my @keytabjc = keys %tabjc; + +my @slice; +my $go; +my $nblinejc; + +if( $cgiparams{'linejc'} eq 'all' ){ $nblinejc = $linesjc; $go=1; } +if( ($cgiparams{'linejc'} != 0) && ($cgiparams{'linejc'} ne 'all') ){ $nblinejc = $cgiparams{'linejc'}; $go=1;} +if( $go != 1){ $nblinejc = 1000; } + +my @key; +my @value; +my $indice=0; +my @tabjc2; + +if ($sortcolumn == 1) +{ + @tabjc2 = sort { $b <=> $a } values (%tabjc); +} +else +{ + @tabjc2 = sort { $a <=> $b } keys (%tabjc); +} + +my $colour=1; + +############################################## +#pie chart generation +use GD::Graph::pie; +use GD::Graph::colour; +#ips sort by hits number +my $v; + +if ($sortcolumn == 1) +{ + for ($v=0;$v<$pienumber;$v++){ + findkey($tabjc2[$v]); + } +} +else +{ + foreach $v (@tabjc2) { + $key[$indice] = $v; + $value[$indice] = $tabjc{$v}; + $indice++; + } +} + +my @ips; +my @numb; + +@ips = @key; +@numb = @value; + +my $o; + +if($cgiparams{'otherspie'} == 2 ){} +else{ + my $numothers; + for($o=0;$o<$pienumber;$o++){ + $numothers = $numothers + $numb[$o]; + } + $numothers = $linesjc - $numothers; + if ($numothers > 0) { + $ips[$pienumber]="$Lang::tr{'otherip'}"; + $numb[$pienumber] = $numothers; + } +} + +my @data = (\@ips,\@numb); +use GD::Graph::colour qw( :files ); +GD::Graph::colour::read_rgb( "/srv/web/ipfire/cgi-bin/logs.cgi/colours.txt" ); + +if ($showpie != 2 && $pienumber <= 50 && $pienumber != 0) { + my $mygraph = GD::Graph::pie->new(500, 350); + $mygraph->set( + 'title' => '', + 'pie_height' => 50, + 'start_angle' => 89 + ) or warn $mygraph->error; + + $mygraph->set_value_font(GD::gdMediumBoldFont); + $mygraph->set( dclrs => [ "colour1" , "colour2" , "colour3" , "colour4" , "colour5" , "colour6" , "colour7" , "colour8" , "colour9" , "colour10" ] ); + my $myimage = $mygraph->plot(\@data) or die $mygraph->error; + + my @filenames = glob("/srv/web/ipfire/html/fwlogs/ip*.png"); + unlink(@filenames); + my $imagerandom = rand(1000000); + my $imagename = "/srv/web/ipfire/html/fwlogs/ip$imagerandom.png"; + open(FILE,">$imagename"); + print FILE $myimage->png; + close(FILE); + ##################################################### + print "";
+ print " ";
+ print " |

| $Lang::tr{'month'}: | ++ | +$Lang::tr{'day'}: | ++ | ++ | + | + |
| $Lang::tr{'Number of Ports for the pie chart'}: | ++ |
$Lang::tr{'firewall hits'} $longmonthstr $daystr: $lines
"; + +my $linesjc = 0; +my %tabjc; + +if ($pienumber == -1 || $pienumber > $lines || $sortcolumn == 2) { $pienumber = $lines; }; +$lines = 0; +foreach $_ (@log) +{ + if($_ =~ /DPT\=([\d\.]+)/){ + $tabjc{$1} = $tabjc{$1} + 1 ; + if(($tabjc{$1} == 1) && ($lines < $pienumber)) { $lines = $lines + 1; } + $linesjc++; + } +} + +$pienumber = $lines; + +my @keytabjc = keys %tabjc; + +my @slice; +my $go; +my $nblinejc; + +if( $cgiparams{'linejc'} eq 'all' ){ $nblinejc = $linesjc; $go=1; } +if( ($cgiparams{'linejc'} != 0) && ($cgiparams{'linejc'} ne 'all') ){ $nblinejc = $cgiparams{'linejc'}; $go=1;} +if( $go != 1){ $nblinejc = 1000; } + +my @key; +my @value; +my $indice=0; +my @tabjc2; + +if ($sortcolumn == 1) +{ + @tabjc2 = sort { $b <=> $a } values (%tabjc); +} +else +{ + @tabjc2 = sort { $a <=> $b } keys (%tabjc); +} + +my $colour=1; + + + +############################################## +#pie chart generation +use GD::Graph::pie; +use GD::Graph::colour; +#ports sort by hits number +#(port - number_of_hit) sorted by number_of_hit +my $v; + +if ($sortcolumn == 1) +{ + for ($v=0;$v<$pienumber;$v++){ + findkey($tabjc2[$v]); + } +} +else +{ + foreach $v (@tabjc2) { + $key[$indice] = $v; + $value[$indice] = $tabjc{$v}; + $indice++; + } +} + +my @ports; +my @numb; + +@ports = @key; +@numb = @value; + +my $o; + +if($cgiparams{'otherspie'} == 2 ){} +else{ + my $numothers; + for($o=0;$o<$pienumber;$o++){ + $numothers = $numothers + $numb[$o]; + } + $numothers = $linesjc - $numothers; + if ($numothers > 0) { + $ports[$pienumber]="$Lang::tr{'otherport'}"; + $numb[$pienumber] = $numothers; + } +} + +my @data = (\@ports,\@numb); +use GD::Graph::colour qw( :files ); +GD::Graph::colour::read_rgb( "/srv/web/ipfire/cgi-bin/logs.cgi/colours.txt" ); + +if ($showpie != 2 && $pienumber <= 50 && $pienumber != 0) { + my $mygraph = GD::Graph::pie->new(500, 350); + $mygraph->set( + 'title' => '', + 'pie_height' => 50, + 'start_angle' => 89 + ) or warn $mygraph->error; + + $mygraph->set_value_font(GD::gdMediumBoldFont); + $mygraph->set( dclrs => [ "colour1" , "colour2" , "colour3" , "colour4" , "colour5" , "colour6" , "colour7" , "colour8" , "colour9" , "colour10" ] ); + my $myimage = $mygraph->plot(\@data) or die $mygraph->error; + + my @filenames = glob("/srv/web/ipfire/html/fwlogs/port*.png"); + unlink(@filenames); + my $imagerandom = rand(1000000); + my $imagename = "/srv/web/ipfire/html/fwlogs/port$imagerandom.png"; + open(FILE,">$imagename"); + print FILE $myimage->png; + close(FILE); + ##################################################### + print "";
+ print " ";
+ print " |
| $Lang::tr{'month'}: | ++ | +$Lang::tr{'day'}: | ++ | ++ | + | + |
| $Lang::tr{'source ip'} |
$Lang::tr{'firewall hits'} $longmonthstr $daystr: $lines
"; + +if ($start == -1) { + $start = $lines - ${Header::viewsize}; } +if ($start >= $lines - ${Header::viewsize}) { $start = $lines - ${Header::viewsize}; }; +if ($start < 0) { $start = 0; } + +my $prev = $start - ${Header::viewsize}; +my $next = $start + ${Header::viewsize}; + +if ($prev < 0) { $prev = 0; } +if ($next >= $lines) { $next = -1 } +if ($start == 0) { $prev = -1; } + +if ($lines != 0) { &oldernewer(); } + +print <| $srcaddr | +
| $dstaddr | +
| $Lang::tr{'month'}: | ++ | +$Lang::tr{'day'}: | ++ | ++ | + | + |
| $Lang::tr{'destination port'} |
$Lang::tr{'firewall hits'} $longmonthstr $daystr: $lines
"; + +if ($start == -1) { + $start = $lines - ${Header::viewsize}; } +if ($start >= $lines - ${Header::viewsize}) { $start = $lines - ${Header::viewsize}; }; +if ($start < 0) { $start = 0; } + +my $prev = $start - ${Header::viewsize}; +my $next = $start + ${Header::viewsize}; + +if ($prev < 0) { $prev = 0; } +if ($next >= $lines) { $next = -1 } +if ($start == 0) { $prev = -1; } + +if ($lines != 0) { &oldernewer(); } + +print <| $srcaddr | +
| $dstaddr | +