$cgiparams{'sortcolumn'} = 1;
my @shortmonths = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug',
$cgiparams{'sortcolumn'} = 1;
my @shortmonths = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug',
- 'Sep', 'Oct', 'Nov', 'Dec' );
+ 'Sep', 'Oct', 'Nov', 'Dec' );
my @longmonths = ( $Lang::tr{'january'}, $Lang::tr{'february'}, $Lang::tr{'march'},
my @longmonths = ( $Lang::tr{'january'}, $Lang::tr{'february'}, $Lang::tr{'march'},
- $Lang::tr{'april'}, $Lang::tr{'may'}, $Lang::tr{'june'}, $Lang::tr{'july'}, $Lang::tr{'august'},
- $Lang::tr{'september'}, $Lang::tr{'october'}, $Lang::tr{'november'},
- $Lang::tr{'december'} );
+ $Lang::tr{'april'}, $Lang::tr{'may'}, $Lang::tr{'june'}, $Lang::tr{'july'}, $Lang::tr{'august'},
+ $Lang::tr{'september'}, $Lang::tr{'october'}, $Lang::tr{'november'},
+ $Lang::tr{'december'} );
- my @temp = split(',',$ENV{'QUERY_STRING'});
- $start = $temp[0];
- $cgiparams{'MONTH'} = $temp[1];
- $cgiparams{'DAY'} = $temp[2];
+ my @temp = split(',',$ENV{'QUERY_STRING'});
+ $start = $temp[0];
+ $cgiparams{'MONTH'} = $temp[1];
+ $cgiparams{'DAY'} = $temp[2];
}
if (!($cgiparams{'MONTH'} =~ /^(0|1|2|3|4|5|6|7|8|9|10|11)$/) ||
!($cgiparams{'DAY'} =~ /^(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)$/))
{
}
if (!($cgiparams{'MONTH'} =~ /^(0|1|2|3|4|5|6|7|8|9|10|11)$/) ||
!($cgiparams{'DAY'} =~ /^(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)$/))
{
- my @temp_then=();
- my @temp_now = localtime(time);
- $temp_now[4] = $cgiparams{'MONTH'};
- $temp_now[3] = $cgiparams{'DAY'};
- @temp_then = localtime(POSIX::mktime(@temp_now) + 86400);
- ## Retrieve the same time on the next day -
- ## 86400 seconds in a day
- $cgiparams{'MONTH'} = $temp_then[4];
- $cgiparams{'DAY'} = $temp_then[3];
+ my @temp_then=();
+ my @temp_now = localtime(time);
+ $temp_now[4] = $cgiparams{'MONTH'};
+ $temp_now[3] = $cgiparams{'DAY'};
+ @temp_then = localtime(POSIX::mktime(@temp_now) + 86400);
+ ## Retrieve the same time on the next day -
+ ## 86400 seconds in a day
+ $cgiparams{'MONTH'} = $temp_then[4];
+ $cgiparams{'DAY'} = $temp_then[3];
- my @temp_then=();
- my @temp_now = localtime(time);
- $temp_now[4] = $cgiparams{'MONTH'};
- $temp_now[3] = $cgiparams{'DAY'};
- @temp_then = localtime(POSIX::mktime(@temp_now) - 86400);
- ## Retrieve the same time on the previous day -
- ## 86400 seconds in a day
- $cgiparams{'MONTH'} = $temp_then[4];
- $cgiparams{'DAY'} = $temp_then[3];
+ my @temp_then=();
+ my @temp_now = localtime(time);
+ $temp_now[4] = $cgiparams{'MONTH'};
+ $temp_now[3] = $cgiparams{'DAY'};
+ @temp_then = localtime(POSIX::mktime(@temp_now) - 86400);
+ ## Retrieve the same time on the previous day -
+ ## 86400 seconds in a day
+ $cgiparams{'MONTH'} = $temp_then[4];
+ $cgiparams{'DAY'} = $temp_then[3];
- my @then = ();
- if ( ( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) ||
- ( $cgiparams{'MONTH'} > $now[4] ) ) {
- @then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1901 ));
- } else {
- @then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1900 ));
- }
- $tdoy = $then[7];
- my $lastleap=($year-1)%4;
- if ($tdoy>$doy) {
- if ($lastleap == 0 && $tdoy < 60) {
- $doy=$tdoy+366;
- } else {
- $doy=$doy+365;
- }
- }
+ my @then = ();
+ if ( ( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) ||
+ ( $cgiparams{'MONTH'} > $now[4] ) ) {
+ @then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1901 ));
+ } else {
+ @then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1900 ));
+ }
+ $tdoy = $then[7];
+ my $lastleap=($year-1)%4;
+ if ($tdoy>$doy) {
+ if ($lastleap == 0 && $tdoy < 60) {
+ $doy=$tdoy+366;
+ } else {
+ $doy=$doy+365;
+ }
+ }
} else {
$filestr="/var/log/messages.$datediff";
$filestr = "$filestr.gz" if -f "$filestr.gz";
}
if (!(open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr)))) {
} else {
$filestr="/var/log/messages.$datediff";
$filestr = "$filestr.gz" if -f "$filestr.gz";
}
if (!(open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr)))) {
- $errormessage = "$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}";
- $skip=1;
- # Note: This is in case the log does not exist for that date
+ $errormessage = "$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}";
+ $skip=1;
+ # Note: This is in case the log does not exist for that date
- $datediff=$datediff-1;
- if ($datediff==0) {
- $filestr="/var/log/messages";
- } else {
- $filestr="/var/log/messages.$datediff";
- $filestr = "$filestr.gz" if -f "$filestr.gz";
- }
- if (!(open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr)))) {
- $errormessage="$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}";
- $skip=1;
- }
- if (!$skip) {
- while (<FILE>) {
- if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=.*)$/) {
- $log[$lines] = $_;
- $lines++;
- }
- }
- close (FILE);
- }
+ $datediff=$datediff-1;
+ if ($datediff==0) {
+ $filestr="/var/log/messages";
+ } else {
+ $filestr="/var/log/messages.$datediff";
+ $filestr = "$filestr.gz" if -f "$filestr.gz";
+ }
+ if (!(open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr)))) {
+ $errormessage="$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}";
+ $skip=1;
+ }
+ if (!$skip) {
+ while (<FILE>) {
+ if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=.*)$/) {
+ $log[$lines] = $_;
+ $lines++;
+ }
+ }
+ close (FILE);
+ }
&Header::openbigbox('100%', 'left', '', $errormessage);
if ($errormessage) {
&Header::openbigbox('100%', 'left', '', $errormessage);
if ($errormessage) {
- &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
- print "<font class='base'>$errormessage </font>\n";
- &Header::closebox();
+ &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
+ print "<font class='base'>$errormessage </font>\n";
+ &Header::closebox();
- print "\t<option ";
- if ($month == $cgiparams{'MONTH'}) {
- print "selected='selected' "; }
- print "value='$month'>$longmonths[$month]</option>\n";
+ print "\t<option ";
+ if ($month == $cgiparams{'MONTH'}) {
+ print "selected='selected' ";
+ }
+ print "value='$month'>$longmonths[$month]</option>\n";
- print "\t<option ";
- if ($day == $cgiparams{'DAY'}) {
- print "selected='selected' "; }
- print "value='$day'>$day</option>\n";
+ print "\t<option ";
+ if ($day == $cgiparams{'DAY'}) {
+ print "selected='selected' ";
+ }
+ print "value='$day'>$day</option>\n";
- if($_ =~ /SRC\=([\d\.]+)/){
- $tabjc{$1} = $tabjc{$1} + 1 ;
- if(($tabjc{$1} == 1) && ($lines < $pienumber)) { $lines = $lines + 1; }
- $linesjc++;
- }
+ # Extract ipv4 or ipv6 address
+ if (($_ =~ /SRC\=(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($_ =~ /SRC\=(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) {
+ $tabjc{$1} = $tabjc{$1} + 1 ;
+ if(($tabjc{$1} == 1) && ($lines < $pienumber)) { $lines = $lines + 1; }
+ $linesjc++;
+ }
- 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 $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;
+ }
&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
if ($showpie != 2 && $pienumber <= 50 && $pienumber != 0) {
&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);
- $mygraph->set(
- 'title' => '',
- 'pie_height' => 50,
- 'start_angle' => 89
- ) or warn $mygraph->error;
-
- $mygraph->set_value_font(GD::gdMediumBoldFont);
- $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");
- unlink(@filenames);
- my $imagerandom = rand(1000000);
- my $imagename = "/srv/web/ipfire/html/graphs/fwlog-ip$imagerandom.png";
- open(FILE,">$imagename");
- print FILE $myimage->png;
- close(FILE);
- #####################################################
- print "<div style='text-align:center'>";
- print "<img src='/graphs/fwlog-ip$imagerandom.png'>";
- print "</div>";
+ 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 => [ "$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");
+ unlink(@filenames);
+ my $imagerandom = rand(1000000);
+ my $imagename = "/srv/web/ipfire/html/graphs/fwlog-ip$imagerandom.png";
+ open(FILE,">$imagename");
+ print FILE $myimage->png;
+ close(FILE);
+ #####################################################
+ print "<div style='text-align:center'>";
+ print "<img src='/graphs/fwlog-ip$imagerandom.png'>";
+ print "</div>";
- $show++;
- $percent = $value[$s] * 100 / $linesjc;
- $percent = sprintf("%.f", $percent);
- $total = $total + $value[$s];
- my $colorIndex = $color % 10;
- if($colorIndex == 0) {
- $colorIndex = 10;
- }
- $col="bgcolor='$color{\"color$colorIndex\"}'";
- print "<tr>";
+ $show++;
+ $percent = $value[$s] * 100 / $linesjc;
+ $percent = sprintf("%.f", $percent);
+ $total = $total + $value[$s];
+ # colors are numbered 1 to 10
+ my $colorIndex = ($color % 10) + 1;
+ $col="bgcolor='$color{\"color$colorIndex\"}'";
+ print "<tr>";
+
+ my $ccode = &GeoIP::lookup($key[$s]);
- my $gi = Geo::IP::PurePerl->new();
- my $ccode = $gi->country_code_by_name($key[$s]);
- my $fcode = lc($ccode);
-
- $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>";
-
- # 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>";
- }
+ $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>";
+
+ # 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#$ccode'><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>";
+}
- 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' $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>
+ # colors are numbered 1 to 10
+ my $colorIndex = ($color % 10) + 1;
+ $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' $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>
- my $v;
- foreach $v (@keytabjc) {
- if ($tabjc{$v} eq $_[0]) {
- delete $tabjc{$v};
- $key[$indice] = "$v";
- $value[$indice] = $_[0];
- $indice++;
- last;
- }
- }
+ my $v;
+ foreach $v (@keytabjc) {
+ if ($tabjc{$v} eq $_[0]) {
+ delete $tabjc{$v};
+ $key[$indice] = "$v";
+ $value[$indice] = $_[0];
+ $indice++;
+ last;
+ }
+ }