]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
No code changes, fixed formatting by replacing spaces with tabs
authorMichael Eitelwein <michael@eitelwein.net>
Sat, 9 Jan 2016 19:09:58 +0000 (20:09 +0100)
committerMichael Eitelwein <michael@eitelwein.net>
Sat, 9 Jan 2016 19:09:58 +0000 (20:09 +0100)
html/cgi-bin/logs.cgi/firewalllog.dat
html/cgi-bin/logs.cgi/firewalllogcountry.dat
html/cgi-bin/logs.cgi/firewalllogip.dat
html/cgi-bin/logs.cgi/firewalllogport.dat
html/cgi-bin/logs.cgi/showrequestfromcountry.dat
html/cgi-bin/logs.cgi/showrequestfromip.dat
html/cgi-bin/logs.cgi/showrequestfromport.dat

index df9b488126406a405957364e096cfb9a05a5b0e6..5c9722b8521f4df04e0c317968df849811492fe7 100644 (file)
@@ -41,11 +41,11 @@ my %logsettings=();
 my $errormessage = '';
 
 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'},
-        $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 @now = localtime();
 my $dow = $now[6];
@@ -66,55 +66,55 @@ my $start = ($logsettings{'LOGVIEW_REVERSE'} eq 'on') ? 0x7FFFF000 : 0; #index o
 
 if ($ENV{'QUERY_STRING'} && $cgiparams{'ACTION'} ne $Lang::tr{'update'})
 {
-        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'} =~ /^(0|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)$/))
+       !($cgiparams{'DAY'} =~ /^(0|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)$/))
 {
-        $cgiparams{'DAY'} = $now[3];
-        $cgiparams{'MONTH'} = $now[4];
+       $cgiparams{'DAY'} = $now[3];
+       $cgiparams{'MONTH'} = $now[4];
 }
 elsif($cgiparams{'ACTION'} eq '>>')
 {
-        my @temp_then=();
-        my @temp_now = localtime(time);
-        $temp_now[4] = $cgiparams{'MONTH'};
-        $temp_now[3] = $cgiparams{'DAY'};
-        if ($cgiparams{'DAY'}) {
-            @temp_then = localtime(POSIX::mktime(@temp_now) + 86400);
-            ## Retrieve the same time on the next day +
-            ## 86400 seconds in a day
-        } else {
-            $temp_now[3] = 1;
-            $temp_now[4] = ($temp_now[4]+1) %12;
-            @temp_then = localtime(POSIX::mktime(@temp_now) );
-            $temp_then[3] = 0;
-        }
-        $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'};
+       if ($cgiparams{'DAY'}) {
+               @temp_then = localtime(POSIX::mktime(@temp_now) + 86400);
+               ## Retrieve the same time on the next day +
+               ## 86400 seconds in a day
+       } else {
+               $temp_now[3] = 1;
+               $temp_now[4] = ($temp_now[4]+1) %12;
+               @temp_then = localtime(POSIX::mktime(@temp_now) );
+               $temp_then[3] = 0;
+       }
+       $cgiparams{'MONTH'} = $temp_then[4];
+       $cgiparams{'DAY'} = $temp_then[3];
 }
 elsif($cgiparams{'ACTION'} eq '<<')
 {
-        my @temp_then=();
-        my @temp_now = localtime(time);
-        $temp_now[4] = $cgiparams{'MONTH'};
-        $temp_now[3] = $cgiparams{'DAY'};
-        if ($cgiparams{'DAY'}) {
-            @temp_then = localtime(POSIX::mktime(@temp_now) - 86400);
-            ## Retrieve the same time on the next day -
-            ## 86400 seconds in a day
-        } else {
-            $temp_now[3] = 1;
-            $temp_now[4] = ($temp_now[4]-1) %12;
-            @temp_then = localtime(POSIX::mktime(@temp_now) );
-            $temp_then[3] = 0;
-        }
-        $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'};
+       if ($cgiparams{'DAY'}) {
+               @temp_then = localtime(POSIX::mktime(@temp_now) - 86400);
+               ## Retrieve the same time on the next day -
+               ## 86400 seconds in a day
+       } else {
+               $temp_now[3] = 1;
+               $temp_now[4] = ($temp_now[4]-1) %12;
+               @temp_then = localtime(POSIX::mktime(@temp_now) );
+               $temp_then[3] = 0;
+       }
+       $cgiparams{'MONTH'} = $temp_then[4];
+       $cgiparams{'DAY'} = $temp_then[3];
 }
 
 # Find in which file.gz is the log. Can be calculated because WEEKLY ROTATING of access.log
@@ -122,104 +122,104 @@ my $gzindex;
 my $date = $cgiparams{'DAY'} == 0 ? '' :  $cgiparams{'DAY'} <= 9 ? "0$cgiparams{'DAY'}" : "$cgiparams{'DAY'}";
 
 {
-    my $xday;
-    
-    # Calculate time. If future date, calculate for past year !!!
-    if (( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) ||
-        ( $cgiparams{'MONTH'}  > $now[4] ) ) {
-        $xday = POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1901 );
-        $date = "$longmonths[$cgiparams{'MONTH'}] $date, ". int($year-1);
-    } else {
-        $xday = POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1900 );
-        $date = "$longmonths[$cgiparams{'MONTH'}] $date, $year";
-    }
-
-    # calculate end of active week (saturday 23H59)
-    my @then = ();
-    @then = localtime(time());
-    my $sunday = POSIX::mktime( 0, 0, 0, @then[3], @then[4], @then[5]);
-    $sunday += (6-$then[6]) * 86400;
-
-    # Convert delta in second to full weeks
-        $gzindex = int (($sunday-$xday)/604800 );
+       my $xday;
+       
+       # Calculate time. If future date, calculate for past year !!!
+       if (( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) ||
+       ( $cgiparams{'MONTH'}  > $now[4] ) ) {
+               $xday = POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1901 );
+               $date = "$longmonths[$cgiparams{'MONTH'}] $date, ". int($year-1);
+       } else {
+               $xday = POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1900 );
+               $date = "$longmonths[$cgiparams{'MONTH'}] $date, $year";
+       }
+
+       # calculate end of active week (saturday 23H59)
+       my @then = ();
+       @then = localtime(time());
+       my $sunday = POSIX::mktime( 0, 0, 0, @then[3], @then[4], @then[5]);
+       $sunday += (6-$then[6]) * 86400;
+
+       # Convert delta in second to full weeks
+       $gzindex = int (($sunday-$xday)/604800 );
 }
-                                                                                           
+
 my $monthstr = $shortmonths[$cgiparams{'MONTH'}];
 my $daystr =  $cgiparams{'DAY'} == 0 ?  '..' : $cgiparams{'DAY'} <= 9 ? " $cgiparams{'DAY'}" : "$cgiparams{'DAY'}";
-       
+
 my $lines = 0;
 my @log=();
 
 my $loop = 1;
 my $filestr = 0;
-my $lastdatetime;           # for debug
+my $lastdatetime;      # for debug
 my $search_for_end = 0;
-            
+
 while ($gzindex >=0 && $loop) {
-        # calculate file name
-        if ($gzindex == 0) {
-            $filestr = "/var/log/messages";
-        } else {
-            $filestr = "/var/log/messages.$gzindex";
-            $filestr = "$filestr.gz" if -f "$filestr.gz";
-        }
-        # now read file if existing
-        if (open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr))) {
-            #&General::log("reading $filestr");
-            READ:while (<FILE>) {
-                my $line = $_;
-                if ($line =~ /^${monthstr} ${daystr} ..:..:.. [\w\-]+ kernel:.*IN=.*$/) {
-                    # when standart viewing, just keep in memory the correct slice
-                    # it starts a '$start' and size is $viewport
-                    # If export, then keep all lines...
-                    if ($cgiparams{'ACTION'} eq $Lang::tr{'export'}){
-                        $log[$lines++] = "$line";
-                    } else {
-                        if ($lines++ < ($start + $Header::viewsize)) {
-                            push(@log,"$line");
-                            if (@log > $Header::viewsize) {
-                                shift (@log);
-                            }
-                        #} else { dont do this optimisation, need to count lines !
-                            #    $datetime = $maxtime; # we have read viewsize lines, stop main loop
-                            #    last READ;           # exit read file
-                        }
-                    }
-                    $search_for_end = 1;        # we find the start of slice, can look for end now
-                } else {
-                    if ($search_for_end == 1) {
-                        #finish read files when date is over (test month equality only)
-                        $line =~ /^(...) (..) ..:..:..*$/;
-                        $loop = 0 if ( ($1 ne $monthstr) || ( ($daystr ne '..') && ($daystr ne $2) ) );
-                    }
-                }
-            }
-            close (FILE);
-        }
-        $gzindex--;     # will try next gz file eg 40,39,38,.... because it may have holes when ipcop stopped
-                        # for a long time
+       # calculate file name
+       if ($gzindex == 0) {
+               $filestr = "/var/log/messages";
+       } else {
+               $filestr = "/var/log/messages.$gzindex";
+               $filestr = "$filestr.gz" if -f "$filestr.gz";
+       }
+       # now read file if existing
+       if (open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr))) {
+               #&General::log("reading $filestr");
+               READ:while (<FILE>) {
+                       my $line = $_;
+                       if ($line =~ /^${monthstr} ${daystr} ..:..:.. [\w\-]+ kernel:.*IN=.*$/) {
+                               # when standart viewing, just keep in memory the correct slice
+                               # it starts a '$start' and size is $viewport
+                               # If export, then keep all lines...
+                               if ($cgiparams{'ACTION'} eq $Lang::tr{'export'}){
+                                       $log[$lines++] = "$line";
+                               } else {
+                                       if ($lines++ < ($start + $Header::viewsize)) {
+                                               push(@log,"$line");
+                                               if (@log > $Header::viewsize) {
+                                                       shift (@log);
+                                               }
+                                       #} else { dont do this optimisation, need to count lines !
+                                       #       $datetime = $maxtime; # we have read viewsize lines, stop main loop
+                                       #       last READ;         # exit read file
+                                       }
+                               }
+                               $search_for_end = 1;    # we find the start of slice, can look for end now
+                       } else {
+                               if ($search_for_end == 1) {
+                                       #finish read files when date is over (test month equality only)
+                                       $line =~ /^(...) (..) ..:..:..*$/;
+                                       $loop = 0 if ( ($1 ne $monthstr) || ( ($daystr ne '..') && ($daystr ne $2) ) );
+                               }
+                       }
+               }
+               close (FILE);
+       }
+       $gzindex--;     # will try next gz file eg 40,39,38,.... because it may have holes when ipcop stopped
+                       # for a long time
 }# while
 
 #  $errormessage = "$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}";
 
 if ($cgiparams{'ACTION'} eq $Lang::tr{'export'})
 {
-        print "Content-type: text/plain\n\n";
-        print "IPFire firewall log\r\n";
-        print "$Lang::{'date'}: $date\r\n\r\n";
-
-        if ($logsettings{'LOGVIEW_REVERSE'} eq 'on') { @log = reverse @log; }
-
-        foreach $_ (@log)
-        {
-                /^... (..) (..:..:..) [\w\-]+ kernel:.*(IN=.*)$/;
-                my $day =  $1;
-                $day =~ tr / /0/;
-                my $time = $cgiparams{'DAY'} ? "$2" : "$day/$2" ;
-                print "$time $3\r\n";
-                
-        }
-        exit 0;
+       print "Content-type: text/plain\n\n";
+       print "IPFire firewall log\r\n";
+       print "$Lang::{'date'}: $date\r\n\r\n";
+
+       if ($logsettings{'LOGVIEW_REVERSE'} eq 'on') { @log = reverse @log; }
+
+       foreach $_ (@log)
+       {
+               /^... (..) (..:..:..) [\w\-]+ kernel:.*(IN=.*)$/;
+               my $day =  $1;
+               $day =~ tr / /0/;
+               my $time = $cgiparams{'DAY'} ? "$2" : "$day/$2" ;
+               print "$time $3\r\n";
+               
+       }
+       exit 0;
 }
 
 &Header::showhttpheaders();
@@ -229,9 +229,9 @@ if ($cgiparams{'ACTION'} eq $Lang::tr{'export'})
 &Header::openbigbox('100%', 'left', '', $errormessage);
 
 if ($errormessage) {
-        &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
-        print "<font class='base'>$errormessage&nbsp;</font>\n";
-        &Header::closebox();
+       &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
+       print "<font class='base'>$errormessage&nbsp;</font>\n";
+       &Header::closebox();
 }
 
 &Header::openbox('100%', 'left', "$Lang::tr{'settings'}");
@@ -240,33 +240,35 @@ print <<END
 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
 <table width='100%'>
 <tr>
-        <td width='10%' class='base'>$Lang::tr{'month'}:&nbsp;</td>
-        <td width='10%'>
-        <select name='MONTH'>
+       <td width='10%' class='base'>$Lang::tr{'month'}:&nbsp;</td>
+       <td width='10%'>
+       <select name='MONTH'>
 END
 ;
 for (my $month = 0; $month < 12; $month++)
 {
-        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 <<END
-        </select>
-        </td>
-        <td width='10%' class='base' align='right'>&nbsp;$Lang::tr{'day'}:&nbsp;</td>
-        <td width='40%'>
-        <select name='DAY'>
+       </select>
+       </td>
+       <td width='10%' class='base' align='right'>&nbsp;$Lang::tr{'day'}:&nbsp;</td>
+       <td width='40%'>
+       <select name='DAY'>
 END
 ;
 print "<option value='0'>$Lang::tr{'all'}</option>\n";
 for (my $day = 1; $day <= 31; $day++) 
 {
-        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";
 }
 print <<END
 </select>
@@ -291,20 +293,20 @@ $start = $lastPageIndex if ($start >= $lastPageIndex);
 $start = 0 if ($start < 0);
 
 my $prev;
-    if ($start == 0) {
-        $prev = -1;
-    } else {
-        $prev = $start - ${Header::viewsize};
-        $prev = 0 if ( $prev < 0);
-    }
-                                    
+if ($start == 0) {
+       $prev = -1;
+} else {
+       $prev = $start - ${Header::viewsize};
+       $prev = 0 if ( $prev < 0);
+}
+                                       
 my $next;
-    if ($start == $lastPageIndex) {
-        $next = -1;
-    } else {
-        $next = $start + ${Header::viewsize};
-        $next = $lines - ${Header::viewsize} if ($next >= $lines - ${Header::viewsize});
-    }
+if ($start == $lastPageIndex) {
+       $next = -1;
+} else {
+       $next = $start + ${Header::viewsize};
+       $next = $lines - ${Header::viewsize} if ($next >= $lines - ${Header::viewsize});
+}
 
 if ($logsettings{'LOGVIEW_REVERSE'} eq 'on') { @log = reverse @log; }
 if ($lines != 0) { &oldernewer(); }
@@ -312,14 +314,14 @@ if ($lines != 0) { &oldernewer(); }
 print <<END
 <table width='100%' class='tbl'>
 <tr>
-        <th align='center' class='boldbase'><b>$Lang::tr{'time'}</b></th>
-        <th align='center' class='boldbase'><b>$Lang::tr{'chain'}</b></th>
-        <th align='center' class='boldbase'><b>$Lang::tr{'iface'}</b></th>
-        <th align='center' class='boldbase'><b>$Lang::tr{'proto'}</b></th>
-        <th align='center' class='boldbase'><b>$Lang::tr{'source'}<br/>$Lang::tr{'destination'}</b></th>
-        <th align='center' class='boldbase'><b>$Lang::tr{'src port'}<br />$Lang::tr{'dst port'}</b></th>
-        <th align='center' class='boldbase'><b>$Lang::tr{'country'}</b></th>
-        <th align='center' class='boldbase'><b>$Lang::tr{'mac address'}</b></th>
+       <th align='center' class='boldbase'><b>$Lang::tr{'time'}</b></th>
+       <th align='center' class='boldbase'><b>$Lang::tr{'chain'}</b></th>
+       <th align='center' class='boldbase'><b>$Lang::tr{'iface'}</b></th>
+       <th align='center' class='boldbase'><b>$Lang::tr{'proto'}</b></th>
+       <th align='center' class='boldbase'><b>$Lang::tr{'source'}<br/>$Lang::tr{'destination'}</b></th>
+       <th align='center' class='boldbase'><b>$Lang::tr{'src port'}<br />$Lang::tr{'dst port'}</b></th>
+       <th align='center' class='boldbase'><b>$Lang::tr{'country'}</b></th>
+       <th align='center' class='boldbase'><b>$Lang::tr{'mac address'}</b></th>
 </tr>
 END
 ;
@@ -330,70 +332,74 @@ foreach $_ (@log)
 {
        # If ipv6 uses a bridge, PHYSIN= contains the relevant iface information
        # otherwise use IN=
-        my $packet = '';
-        if ($_ =~ /^... (..) (..:..:..) [\w\-]+ kernel:(.*)(IN=.*)(PHYSIN=.*)$/) { $packet = $5; }
-        elsif ($_ =~ /^... (..) (..:..:..) [\w\-]+ kernel:(.*)(IN=.*)$/) { $packet = $4; }
-        my $day =  $1;
-        $day =~ tr / /0/;
-        my $time = $cgiparams{'DAY'} ? "$2" : "$day/$2" ;
-        my $chain = $3; 
-
-               my ($iface, $srcaddr, $dstaddr, $macaddr, $proto, $srcport, $dstport);
-               if ($packet =~ /PHYSIN=(\w+)/) { $iface=$1; } elsif ($packet =~ /IN=(\w+)/) { $iface = $1; }
-               # Identify whether ipv4 or ipv6. Both are mutally exclusive.
-               if ($packet =~ /SRC\=(([\d]{1,3})(\.([\d]{1,3})){3})/) { $srcaddr=$1; }
-                if ($packet =~ /SRC\=(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/) { $srcaddr=$1; }
-               if ($packet =~ /DST\=(([\d]{1,3})(\.([\d]{1,3})){3})/) { $dstaddr=$1; }
-                if ($packet =~ /DST\=(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/) { $dstaddr=$1; }
-               $macaddr=$1 if $packet =~ /MAC=([\w+\:]+)/;
-               $proto=$1   if $packet =~ /PROTO=(\w+)/;
-               $srcport=$1 if $packet =~ /SPT=(\d+)/;
-               $dstport=$1 if $packet =~ /DPT=(\d+)/;
-
-        my $gi = Geo::IP::PurePerl->new();
-        my $ccode = $gi->country_code_by_name($srcaddr);
-        my $fcode = lc($ccode);
-
-        my $servi = uc(getservbyport($srcport, lc($proto)));
-        if ($servi ne '' && $srcport < 1024) {
-                $srcport = "$srcport($servi)"; }
-        $servi = uc(getservbyport($dstport, lc($proto)));
-        if ($servi ne '' && $dstport < 1024) {
-                $dstport = "$dstport($servi)";}
-        my @mactemp = split(/:/,$macaddr);
-        $macaddr = "$mactemp[6]:$mactemp[7]:$mactemp[8]:$mactemp[9]:$mactemp[10]:$mactemp[11]";
-        my $col="";
-        if ($lines % 2) {
-                print "<tr>";
-                $col="bgcolor='$color{'color20'}'"; }
-        else {
-                print "<tr>";
-                $col="bgcolor='$color{'color22'}'"; }
-        print <<END
-
-        <td align='center' $col>$time</td>
-        <td align='center' $col>$chain</td>
-        <td align='center' $col>$iface</td>
-        <td align='center' $col>$proto</td>
-        <td align='center' $col><a href='/cgi-bin/ipinfo.cgi?ip=$srcaddr'>$srcaddr</a><br /><a href='/cgi-bin/ipinfo.cgi?ip=$dstaddr'>$dstaddr</a></td>
-        <td align='center' $col>$srcport<br/>$dstport</td>
+       my $packet = '';
+       if ($_ =~ /^... (..) (..:..:..) [\w\-]+ kernel:(.*)(IN=.*)(PHYSIN=.*)$/) { $packet = $5; }
+       elsif ($_ =~ /^... (..) (..:..:..) [\w\-]+ kernel:(.*)(IN=.*)$/) { $packet = $4; }
+       my $day =  $1;
+       $day =~ tr / /0/;
+       my $time = $cgiparams{'DAY'} ? "$2" : "$day/$2" ;
+       my $chain = $3; 
+
+       my ($iface, $srcaddr, $dstaddr, $macaddr, $proto, $srcport, $dstport);
+       if ($packet =~ /PHYSIN=(\w+)/) { $iface=$1; } elsif ($packet =~ /IN=(\w+)/) { $iface = $1; }
+       # Identify whether ipv4 or ipv6. Both are mutally exclusive.
+       if ($packet =~ /SRC\=(([\d]{1,3})(\.([\d]{1,3})){3})/) { $srcaddr=$1; }
+       if ($packet =~ /SRC\=(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/) { $srcaddr=$1; }
+       if ($packet =~ /DST\=(([\d]{1,3})(\.([\d]{1,3})){3})/) { $dstaddr=$1; }
+       if ($packet =~ /DST\=(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/) { $dstaddr=$1; }
+       $macaddr=$1 if $packet =~ /MAC=([\w+\:]+)/;
+       $proto=$1   if $packet =~ /PROTO=(\w+)/;
+       $srcport=$1 if $packet =~ /SPT=(\d+)/;
+       $dstport=$1 if $packet =~ /DPT=(\d+)/;
+
+       my $gi = Geo::IP::PurePerl->new();
+       my $ccode = $gi->country_code_by_name($srcaddr);
+       my $fcode = lc($ccode);
+
+       my $servi = uc(getservbyport($srcport, lc($proto)));
+       if ($servi ne '' && $srcport < 1024) {
+               $srcport = "$srcport($servi)"; 
+       }
+       $servi = uc(getservbyport($dstport, lc($proto)));
+       if ($servi ne '' && $dstport < 1024) {
+               $dstport = "$dstport($servi)";
+       }
+       my @mactemp = split(/:/,$macaddr);
+       $macaddr = "$mactemp[6]:$mactemp[7]:$mactemp[8]:$mactemp[9]:$mactemp[10]:$mactemp[11]";
+       my $col="";
+       if ($lines % 2) {
+               print "<tr>";
+               $col="bgcolor='$color{'color20'}'"; 
+       }
+       else {
+               print "<tr>";
+               $col="bgcolor='$color{'color22'}'"; 
+       }
+       print <<END
+
+       <td align='center' $col>$time</td>
+       <td align='center' $col>$chain</td>
+       <td align='center' $col>$iface</td>
+       <td align='center' $col>$proto</td>
+       <td align='center' $col><a href='/cgi-bin/ipinfo.cgi?ip=$srcaddr'>$srcaddr</a><br /><a href='/cgi-bin/ipinfo.cgi?ip=$dstaddr'>$dstaddr</a></td>
+       <td align='center' $col>$srcport<br/>$dstport</td>
 END
-;
+       ;
        # Get flag icon for of the country.
        my $flag_icon = &GeoIP::get_flag_icon($fcode);
 
-        if ( $flag_icon) {
+       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>
+       print <<END
+       <td align='center' $col>$macaddr</td>
+       </tr>
 END
-        ;
-        $lines++;
+       ;
+       $lines++;
 }
 
 print "</table>";
@@ -408,32 +414,36 @@ print "</table>";
 
 sub oldernewer
 {
-print <<END
-<table width='100%'>
-<tr>
+       print <<END
+       <table width='100%'>
+       <tr>
 END
-;
+       ;
 
-print "<td align='center' width='50%'>";
-if ($prev != -1) {
-        print "<a href='/cgi-bin/logs.cgi/firewalllog.dat?0,$cgiparams{'MONTH'},$cgiparams{'DAY'}'>$Lang::tr{'first'}</a> "; 
-        print "<a href='/cgi-bin/logs.cgi/firewalllog.dat?$prev,$cgiparams{'MONTH'},$cgiparams{'DAY'}'>$Lang::tr{'older'}</a>"; }
-else {
-        print "$Lang::tr{'first'} $Lang::tr{'older'}"; }
-print "</td>\n";
-
-print "<td align='center' width='50%'>";
-if ($next >= 0) {
-        print "<a href='/cgi-bin/logs.cgi/firewalllog.dat?$next,$cgiparams{'MONTH'},$cgiparams{'DAY'}'>$Lang::tr{'newer'}</a> ";
-        print "<a href='/cgi-bin/logs.cgi/firewalllog.dat?$lastPageIndex,$cgiparams{'MONTH'},$cgiparams{'DAY'}'>$Lang::tr{'last'}</a>"; }      
-else {
-        print "$Lang::tr{'newer'} $Lang::tr{'last'} "; }
-print "</td>\n";
+       print "<td align='center' width='50%'>";
+       if ($prev != -1) {
+               print "<a href='/cgi-bin/logs.cgi/firewalllog.dat?0,$cgiparams{'MONTH'},$cgiparams{'DAY'}'>$Lang::tr{'first'}</a> "; 
+               print "<a href='/cgi-bin/logs.cgi/firewalllog.dat?$prev,$cgiparams{'MONTH'},$cgiparams{'DAY'}'>$Lang::tr{'older'}</a>"; 
+       }
+       else {
+               print "$Lang::tr{'first'} $Lang::tr{'older'}"; 
+       }
+       print "</td>\n";
 
-print <<END
-</tr>
-</table>
+       print "<td align='center' width='50%'>";
+       if ($next >= 0) {
+               print "<a href='/cgi-bin/logs.cgi/firewalllog.dat?$next,$cgiparams{'MONTH'},$cgiparams{'DAY'}'>$Lang::tr{'newer'}</a> ";
+               print "<a href='/cgi-bin/logs.cgi/firewalllog.dat?$lastPageIndex,$cgiparams{'MONTH'},$cgiparams{'DAY'}'>$Lang::tr{'last'}</a>"; 
+       }
+       else {
+               print "$Lang::tr{'newer'} $Lang::tr{'last'} "; 
+       }
+       print "</td>\n";
+
+       print <<END
+       </tr>
+       </table>
 END
-;
+       ;
 }
 
index 087b844432e3c39c4deacc5a04e6e15b70b446d2..26920b5da0dd97b2831da177cd70c418018f5e27 100644 (file)
@@ -8,7 +8,7 @@
 # page inspired from the initial firewalllog.dat
 #
 # Modified for IPFire by Christian Schmidt
-#                            and Michael Tremer (www.ipfire.org)
+#                          and Michael Tremer (www.ipfire.org)
 
 use strict;
 use Geo::IP::PurePerl;
@@ -39,11 +39,11 @@ $cgiparams{'showpie'} = 1;
 $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'},
-        $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 @now = localtime();
 my $dow = $now[6];
@@ -69,81 +69,81 @@ if ($cgiparams{'sortcolumn'} != 0) { $settings{'sortcolumn'} = $cgiparams{'sortc
 
 if ($cgiparams{'ACTION'} eq $Lang::tr{'save'})
 {
-   &General::writehash("${General::swroot}/fwlogs/ipsettings", \%settings);
+        &General::writehash("${General::swroot}/fwlogs/ipsettings", \%settings);
 }
 
 my $start = -1;
 if ($ENV{'QUERY_STRING'} && $cgiparams{'ACTION'} ne $Lang::tr{'update'})
 {
-        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)$/))
 {
-        $cgiparams{'DAY'} = $now[3];
-        $cgiparams{'MONTH'} = $now[4];
+       $cgiparams{'DAY'} = $now[3];
+       $cgiparams{'MONTH'} = $now[4];
 }
 elsif($cgiparams{'ACTION'} eq '>>')
 {
-        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];
 }
 elsif($cgiparams{'ACTION'} eq '<<')
 {
-        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];
 }
 
 if (($cgiparams{'DAY'} ne $now[3]) || ($cgiparams{'MONTH'} ne $now[4]))
 {
-        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;
+               }
+       }
 }
 
 my $datediff=0;
 my $dowd=0;
 my $multifile=0;
 if ($tdoy ne $doy) {
-        $datediff=int(($doy-$tdoy)/7);
-        $dowd=($doy-$tdoy)%7;
-        if (($dow-$dowd)<1) {
-                $datediff=$datediff+1;
-        }
-        if (($dow-$dowd)==0) {
-                $multifile=1;
-        }
+       $datediff=int(($doy-$tdoy)/7);
+       $dowd=($doy-$tdoy)%7;
+       if (($dow-$dowd)<1) {
+               $datediff=$datediff+1;
+       }
+       if (($dow-$dowd)==0) {
+               $multifile=1;
+       }
 }
 
 my $monthstr = $shortmonths[$cgiparams{'MONTH'}];
@@ -151,62 +151,63 @@ my $longmonthstr = $longmonths[$cgiparams{'MONTH'}];
 my $day = $cgiparams{'DAY'};
 my $daystr='';
 if ($day <= 9) {
-        $daystr = " $day"; }
+       $daystr = " $day"; 
+}
 else {
-        $daystr = $day;
+       $daystr = $day;
 }
 
 my $skip=0;
 my $filestr='';
 if ($datediff==0) {
-        $filestr="/var/log/messages";
+       $filestr="/var/log/messages";
 } else {
-       $filestr="/var/log/messages.$datediff";
-       $filestr = "$filestr.gz" if -f "$filestr.gz";
+                        $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
 }
 my $lines = 0;
 my @log=();
 
 if (!$skip)
 {
-        while (<FILE>)
-        {
-                if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=.*)$/) {
-                        $log[$lines] = $_;
-                        $lines++;
-                }
-        }
-        close (FILE);   
+       while (<FILE>)
+       {
+               if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=.*)$/) {
+                       $log[$lines] = $_;
+                       $lines++;
+               }
+       }
+       close (FILE);   
 }
 
 $skip=0;
 if ($multifile) {
-        $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);
+       }
 }
 
 my $MODNAME="fwlogs";
@@ -217,9 +218,9 @@ my $MODNAME="fwlogs";
 
 
 if ($errormessage) {
-        &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
-        print "<font class='base'>$errormessage&nbsp;</font>\n";
-        &Header::closebox();
+       &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
+       print "<font class='base'>$errormessage&nbsp;</font>\n";
+       &Header::closebox();
 }
 
 &Header::openbox('100%', 'left', "$Lang::tr{'settings'}");
@@ -228,33 +229,33 @@ print <<END
 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
 <table width='100%'>
 <tr>
-        <td width='10%' class='base'>$Lang::tr{'month'}:&nbsp;</td>
-        <td width='10%'>
-        <select name='MONTH'>
+       <td width='10%' class='base'>$Lang::tr{'month'}:&nbsp;</td>
+       <td width='10%'>
+       <select name='MONTH'>
 END
 ;
 my $month;
 for ($month = 0; $month < 12; $month++)
 {
-        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 <<END
-        </select>
-        </td>
-        <td width='10%' class='base' align='right'>&nbsp;$Lang::tr{'day'}:&nbsp;</td>
-        <td width='40%'>
-        <select name='DAY'>
+       </select>
+       </td>
+       <td width='10%' class='base' align='right'>&nbsp;$Lang::tr{'day'}:&nbsp;</td>
+       <td width='40%'>
+       <select name='DAY'>
 END
 ;
 for ($day = 1; $day <= 31; $day++) 
 {
-        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( $cgiparams{'pienumber'} != 0){$pienumber=$cgiparams{'pienumber'};}
@@ -293,43 +294,43 @@ $lines = 0;
 
 foreach $_ (@log)
 {
-  # If ipv6 uses bridge, use PHYSIN for iface, otherwise IN
-  if    (/^... (..) (..:..:..) [\w\-]+ kernel:(.*)(PHYSIN=.*)$/) {}
-  elsif (/^... (..) (..:..:..) [\w\-]+ kernel:(.*)(IN=.*)$/) {}
-  my $packet = $4;
-  my $iface  = '';
-  if ($packet =~ /PHYSIN=(\w+)/) { $iface = $1; } elsif ($packet =~ /IN=(\w+)/) { $iface = $1; }
-  if ( $1 =~ /2./ ) { $iface=''; }
-  my $srcaddr = '';
-  # Find ipv4 and ipv6 addresses
-  if    ($packet =~ /SRC\=(([\d]{1,3})(\.([\d]{1,3})){3})/) { $srcaddr = $1; }
-  elsif ($packet =~ /SRC\=(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/) { $srcaddr = $1; }
-
-  if($iface eq $red_interface) {
-    # Traffic from red
-    if($srcaddr ne '') {
-      # srcaddr is set
-      my $ccode = $gi->country_code_by_name($srcaddr);
-      if ($ccode eq '') {
-          $ccode = 'unknown';
-      }
-      $tabjc{$ccode} = $tabjc{$ccode} + 1 ;
-      if(($tabjc{$ccode} == 1) && ($lines < $pienumber)) { $lines = $lines + 1; }
-      $linesjc++;
-    }
-  }
-  else {
-    # Traffic not from red
-    if($iface ne '') {
-        $tabjc{$iface} = $tabjc{$iface} + 1 ;
-        if(($tabjc{$iface} == 1) && ($lines < $pienumber)) { $lines = $lines + 1; }
-        $linesjc++;
-    }
-    else {
-      # What to do with empty iface lines?
-      # This probably is traffic from ipfire itself (IN= OUT=XY)?
-    }
-  }
+       # If ipv6 uses bridge, use PHYSIN for iface, otherwise IN
+       if    (/^... (..) (..:..:..) [\w\-]+ kernel:(.*)(PHYSIN=.*)$/) {}
+       elsif (/^... (..) (..:..:..) [\w\-]+ kernel:(.*)(IN=.*)$/) {}
+       my $packet = $4;
+       my $iface  = '';
+       if ($packet =~ /PHYSIN=(\w+)/) { $iface = $1; } elsif ($packet =~ /IN=(\w+)/) { $iface = $1; }
+       if ( $1 =~ /2./ ) { $iface=''; }
+       my $srcaddr = '';
+       # Find ipv4 and ipv6 addresses
+       if    ($packet =~ /SRC\=(([\d]{1,3})(\.([\d]{1,3})){3})/) { $srcaddr = $1; }
+       elsif ($packet =~ /SRC\=(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/) { $srcaddr = $1; }
+
+       if($iface eq $red_interface) {
+               # Traffic from red
+               if($srcaddr ne '') {
+                       # srcaddr is set
+                       my $ccode = $gi->country_code_by_name($srcaddr);
+                       if ($ccode eq '') {
+                               $ccode = 'unknown';
+                       }
+                       $tabjc{$ccode} = $tabjc{$ccode} + 1;
+                       if(($tabjc{$ccode} == 1) && ($lines < $pienumber)) { $lines = $lines + 1; }
+                       $linesjc++;
+               }
+       }
+       else {
+               # Traffic not from red
+               if($iface ne '') {
+                       $tabjc{$iface} = $tabjc{$iface} + 1 ;
+                       if(($tabjc{$iface} == 1) && ($lines < $pienumber)) { $lines = $lines + 1; }
+                       $linesjc++;
+               }
+               else {
+                       # What to do with empty iface lines?
+                       # This probably is traffic from ipfire itself (IN= OUT=XY)?
+               }
+       }
 }
 
 $pienumber = $lines;
@@ -349,13 +350,11 @@ my @value;
 my $indice=0;
 my @tabjc2;
 
-if ($sortcolumn == 1)
-{
-        @tabjc2 = sort { $b <=> $a } values (%tabjc);
+if ($sortcolumn == 1) {
+       @tabjc2 = sort { $b <=> $a } values (%tabjc);
 }
-else
-{
-        @tabjc2 = sort { $a <=> $b } keys (%tabjc);
+else {
+       @tabjc2 = sort { $a <=> $b } keys (%tabjc);
 }
 
 my $colour=1;
@@ -367,19 +366,17 @@ use GD::Graph::colour;
 #ips sort by hits number
 my $v;
 
-if ($sortcolumn == 1)
-{
-        for ($v=0;$v<$pienumber;$v++){
-          findkey($tabjc2[$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++;
-        }
+else {
+       foreach $v (@tabjc2) {
+               $key[$indice] = $v;
+               $value[$indice] = $tabjc{$v};
+               $indice++;
+       }
 }
 
 my @ips;
@@ -392,15 +389,15 @@ 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 $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);
@@ -413,28 +410,28 @@ my %mainsettings = ();
 &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-country*.png");
-        unlink(@filenames);
-        my $imagerandom = rand(1000000);
-        my $imagename = "/srv/web/ipfire/html/graphs/fwlog-country$imagerandom.png";
-        open(FILE,">$imagename");
-        print FILE $myimage->png;
-        close(FILE);
-        #####################################################
-        print "<div style='text-align:center;'>";
-        print "<img src='/graphs/fwlog-country$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-country*.png");
+       unlink(@filenames);
+       my $imagerandom = rand(1000000);
+       my $imagename = "/srv/web/ipfire/html/graphs/fwlog-country$imagerandom.png";
+       open(FILE,">$imagename");
+       print FILE $myimage->png;
+       close(FILE);
+       #####################################################
+       print "<div style='text-align:center;'>";
+       print "<img src='/graphs/fwlog-country$imagerandom.png'>";
+       print "</div>";
 }
 print <<END
 <table width='100%' class='tbl'>
@@ -456,72 +453,72 @@ my $col="";
 
 for($s=0;$s<$lines;$s++)
 {
-  $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\"}'";
-  $color++;
-  print "<tr>";
-
-  print "<td align='center' $col>";
-
-  # Dont show details button for "unknown" location.
-  if ($key[$s] ne 'unknown') {
-       print"<form method='post' action='showrequestfromcountry.dat'>";
-       print"<input type='hidden' name='MONTH' value='$cgiparams{'MONTH'}'>";
-       print"<input type='hidden' name='DAY' value='$cgiparams{'DAY'}'>";
-       print"<input type='hidden' name='country' value='$key[$s]'>";
-       print"<input type='submit' value='details'></form>";
-  }
-  elsif ($key[$s] eq 'unknown') {
-        print "unknown";
-  }
-  # Looks dangerous to use hardcoded interface names here. Probably needs fixing.
-  if ($key[$s] eq 'blue0' || $key[$s] eq 'green0' || $key[$s] eq 'orange0' ) {
-      print "<td align='center' $col>$key[$s]</td>";
-  }
-  else {
-       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 {
+       $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\"}'";
+       $color++;
+       print "<tr>";
+
+       print "<td align='center' $col>";
+
+       # Dont show details button for "unknown" location.
+       if ($key[$s] ne 'unknown') {
+               print"<form method='post' action='showrequestfromcountry.dat'>";
+               print"<input type='hidden' name='MONTH' value='$cgiparams{'MONTH'}'>";
+               print"<input type='hidden' name='DAY' value='$cgiparams{'DAY'}'>";
+               print"<input type='hidden' name='country' value='$key[$s]'>";
+               print"<input type='submit' value='details'></form>";
+       }
+       elsif ($key[$s] eq 'unknown') {
+               print "unknown";
+       }
+       # Looks dangerous to use hardcoded interface names here. Probably needs fixing.
+       if ($key[$s] eq 'blue0' || $key[$s] eq 'green0' || $key[$s] eq 'orange0' ) {
                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>";
+       }
+       else {
+               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>";
+       print "<td align='center' $col>$percent</td>";
+       print "</tr>";
 }
 
 if($cgiparams{'otherspie'} == 2 ){}
 else{
-  # 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{'other countries'}</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{'other countries'}</td>
+               <td align='center' $col>$dif</TD>
+               <td align='center' $col>$percent</TD>
+               </tr>
 END
-;
-}
+               ;
+       }
 }
 print <<END
 </TABLE>
@@ -533,19 +530,19 @@ END
 &Header::closepage();
 
 sub findkey {
-  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;
+               }
+       }
 }
 sub checkversion {
-        #Automatic Updates is disabled
-        return "0","0";
+       #Automatic Updates is disabled
+       return "0","0";
 }
 
index 6fc34223e1264b2491dd4c6db991f0f3e7045f00..08ef1c4be1425246971658939cb9c73171b63d45 100644 (file)
@@ -8,7 +8,7 @@
 # page inspired from the initial firewalllog.dat
 #
 # Modified for IPFire by Christian Schmidt
-#                            and Michael Tremer (www.ipfire.org)
+#                          and Michael Tremer (www.ipfire.org)
 
 use strict;
 use Geo::IP::PurePerl;
@@ -39,11 +39,11 @@ $cgiparams{'showpie'} = 1;
 $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'},
-        $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 @now = localtime();
 my $dow = $now[6];
@@ -69,81 +69,81 @@ if ($cgiparams{'sortcolumn'} != 0) { $settings{'sortcolumn'} = $cgiparams{'sortc
 
 if ($cgiparams{'ACTION'} eq $Lang::tr{'save'})
 {
-   &General::writehash("${General::swroot}/fwlogs/ipsettings", \%settings);
+       &General::writehash("${General::swroot}/fwlogs/ipsettings", \%settings);
 }
 
 my $start = -1;
 if ($ENV{'QUERY_STRING'} && $cgiparams{'ACTION'} ne $Lang::tr{'update'})
 {
-        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)$/))
 {
-        $cgiparams{'DAY'} = $now[3];
-        $cgiparams{'MONTH'} = $now[4];
+       $cgiparams{'DAY'} = $now[3];
+       $cgiparams{'MONTH'} = $now[4];
 }
 elsif($cgiparams{'ACTION'} eq '>>')
 {
-        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];
 }
 elsif($cgiparams{'ACTION'} eq '<<')
 {
-        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];
 }
 
 if (($cgiparams{'DAY'} ne $now[3]) || ($cgiparams{'MONTH'} ne $now[4]))
 {
-        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;
+               }
+       }
 }
 
 my $datediff=0;
 my $dowd=0;
 my $multifile=0;
 if ($tdoy ne $doy) {
-        $datediff=int(($doy-$tdoy)/7);
-        $dowd=($doy-$tdoy)%7;
-        if (($dow-$dowd)<1) {
-                $datediff=$datediff+1;
-        }
-        if (($dow-$dowd)==0) {
-                $multifile=1;
-        }
+       $datediff=int(($doy-$tdoy)/7);
+       $dowd=($doy-$tdoy)%7;
+       if (($dow-$dowd)<1) {
+               $datediff=$datediff+1;
+       }
+       if (($dow-$dowd)==0) {
+               $multifile=1;
+       }
 }
 
 my $monthstr = $shortmonths[$cgiparams{'MONTH'}];
@@ -151,62 +151,62 @@ my $longmonthstr = $longmonths[$cgiparams{'MONTH'}];
 my $day = $cgiparams{'DAY'};
 my $daystr='';
 if ($day <= 9) {
-        $daystr = " $day"; }
+       $daystr = " $day"; }
 else {
-        $daystr = $day;
+       $daystr = $day;
 }
 
 my $skip=0;
 my $filestr='';
 if ($datediff==0) {
-        $filestr="/var/log/messages";
+       $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;
-        # 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
 }
 my $lines = 0;
 my @log=();
 
 if (!$skip)
 {
-        while (<FILE>)
-        {
-                if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=.*)$/) {
-                        $log[$lines] = $_;
-                        $lines++;
-                }
-        }
-        close (FILE);   
+       while (<FILE>)
+       {
+               if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=.*)$/) {
+                       $log[$lines] = $_;
+                       $lines++;
+               }
+       }
+       close (FILE);   
 }
 
 $skip=0;
 if ($multifile) {
-        $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);
+       }
 }
 
 my $MODNAME="fwlogs";
@@ -217,9 +217,9 @@ my $MODNAME="fwlogs";
 
 
 if ($errormessage) {
-        &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
-        print "<font class='base'>$errormessage&nbsp;</font>\n";
-        &Header::closebox();
+       &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
+       print "<font class='base'>$errormessage&nbsp;</font>\n";
+       &Header::closebox();
 }
 
 &Header::openbox('100%', 'left', "$Lang::tr{'settings'}");
@@ -228,33 +228,35 @@ print <<END
 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
 <table width='100%'>
 <tr>
-        <td width='10%' class='base'>$Lang::tr{'month'}:&nbsp;</td>
-        <td width='10%'>
-        <select name='MONTH'>
+       <td width='10%' class='base'>$Lang::tr{'month'}:&nbsp;</td>
+       <td width='10%'>
+       <select name='MONTH'>
 END
 ;
 my $month;
 for ($month = 0; $month < 12; $month++)
 {
-        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 <<END
-        </select>
-        </td>
-        <td width='10%' class='base' align='right'>&nbsp;$Lang::tr{'day'}:&nbsp;</td>
-        <td width='40%'>
-        <select name='DAY'>
+       </select>
+       </td>
+       <td width='10%' class='base' align='right'>&nbsp;$Lang::tr{'day'}:&nbsp;</td>
+       <td width='40%'>
+       <select name='DAY'>
 END
 ;
 for ($day = 1; $day <= 31; $day++) 
 {
-        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( $cgiparams{'pienumber'} != 0){$pienumber=$cgiparams{'pienumber'};}
@@ -291,12 +293,12 @@ if ($pienumber == -1 || $pienumber > $lines || $sortcolumn == 2) { $pienumber =
 $lines = 0;
 foreach $_ (@log)
 {
-  # 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++;
-  }
+       # 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++;
+       }
 }
 
 $pienumber = $lines;
@@ -318,11 +320,11 @@ my @tabjc2;
 
 if ($sortcolumn == 1)
 {
-        @tabjc2 = sort { $b <=> $a } values (%tabjc);
+       @tabjc2 = sort { $b <=> $a } values (%tabjc);
 }
 else
 {
-        @tabjc2 = sort { $a <=> $b } keys (%tabjc);
+       @tabjc2 = sort { $a <=> $b } keys (%tabjc);
 }
 
 my $colour=1;
@@ -336,17 +338,17 @@ my $v;
 
 if ($sortcolumn == 1)
 {
-        for ($v=0;$v<$pienumber;$v++){
-          findkey($tabjc2[$v]);
-        }
+       for ($v=0;$v<$pienumber;$v++){
+               findkey($tabjc2[$v]);
+       }
 }
 else
 {
-        foreach $v (@tabjc2) {
-          $key[$indice] = $v;
-          $value[$indice] = $tabjc{$v};
-          $indice++;
-        }
+       foreach $v (@tabjc2) {
+               $key[$indice] = $v;
+               $value[$indice] = $tabjc{$v};
+               $indice++;
+       }
 }
 
 my @ips;
@@ -359,15 +361,15 @@ 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 $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);
@@ -380,28 +382,28 @@ my %mainsettings = ();
 &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>";
 }
 
 print <<END
@@ -425,60 +427,60 @@ my $col="";
 
 for($s=0;$s<$lines;$s++)
 {
-  $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>";
+       $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 $gi = Geo::IP::PurePerl->new();
+       my $ccode = $gi->country_code_by_name($key[$s]);
+       my $fcode = lc($ccode);
   
-  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#$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 ){}
 else{
-  # 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>
+       # 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>
 END
-;
-}
+               ;
+       }
 }
 print <<END
 </table>
@@ -490,20 +492,20 @@ END
 &Header::closepage();
 
 sub findkey {
-  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;
+               }
+       }
 }
 
 sub checkversion {
-    #Automatic Updates is disabled
-    return "0","0";
+       #Automatic Updates is disabled
+       return "0","0";
 }
 
index 583c1b3d3e775e2e1a62264d1a32ac593fa256f0..fbc92e43bbc09173ebb5ad59f9c26365698a24b0 100644 (file)
@@ -8,7 +8,7 @@
 # page inspired from the initial firewalllog.dat
 #
 # Modified for IPFire by Christian Schmidt
-#                            and Michael Tremer (www.ipfire.org)
+#                       and Michael Tremer (www.ipfire.org)
 
 use strict;
 
@@ -40,11 +40,11 @@ $cgiparams{'showpie'} = 1;
 $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'},
-        $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 @now = localtime();
 my $dow = $now[6];
@@ -70,81 +70,81 @@ if ($cgiparams{'sortcolumn'} != 0) { $settings{'sortcolumn'} = $cgiparams{'sortc
 
 if ($cgiparams{'ACTION'} eq $Lang::tr{'save'})
 {
-   &General::writehash("${General::swroot}/fwlogs/portsettings", \%settings);
+       &General::writehash("${General::swroot}/fwlogs/portsettings", \%settings);
 }
 
 my $start = -1;
 if ($ENV{'QUERY_STRING'} && $cgiparams{'ACTION'} ne $Lang::tr{'update'})
 {
-        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)$/))
 {
-        $cgiparams{'DAY'} = $now[3];
-        $cgiparams{'MONTH'} = $now[4];
+       $cgiparams{'DAY'} = $now[3];
+       $cgiparams{'MONTH'} = $now[4];
 }
 elsif($cgiparams{'ACTION'} eq '>>')
 {
-        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];
 }
 elsif($cgiparams{'ACTION'} eq '<<')
 {
-        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];
 }
 
 if (($cgiparams{'DAY'} ne $now[3]) || ($cgiparams{'MONTH'} ne $now[4]))
 {
-        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;
+               }
+       }
 }
 
 my $datediff=0;
 my $dowd=0;
 my $multifile=0;
 if ($tdoy ne $doy) {
-        $datediff=int(($doy-$tdoy)/7);
-        $dowd=($doy-$tdoy)%7;
-        if (($dow-$dowd)<1) {
-                $datediff=$datediff+1;
-        }
-        if (($dow-$dowd)==0) {
-                $multifile=1;
-        }
+       $datediff=int(($doy-$tdoy)/7);
+       $dowd=($doy-$tdoy)%7;
+       if (($dow-$dowd)<1) {
+               $datediff=$datediff+1;
+       }
+       if (($dow-$dowd)==0) {
+               $multifile=1;
+       }
 }
 
 my $monthstr = $shortmonths[$cgiparams{'MONTH'}];
@@ -152,62 +152,62 @@ my $longmonthstr = $longmonths[$cgiparams{'MONTH'}];
 my $day = $cgiparams{'DAY'};
 my $daystr='';
 if ($day <= 9) {
-        $daystr = " $day"; }
+       $daystr = " $day"; }
 else {
-        $daystr = $day;
+       $daystr = $day;
 }
 
 my $skip=0;
 my $filestr='';
 if ($datediff==0) {
-        $filestr="/var/log/messages";
+       $filestr="/var/log/messages";
 } else {
-       $filestr="/var/log/messages.$datediff";
-       $filestr = "$filestr.gz" if -f "$filestr.gz";
+       $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
 }
 my $lines = 0;
 my @log=();
 
 if (!$skip)
 {
-        while (<FILE>)
-        {
-                if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=.*)$/) {
-                        $log[$lines] = $_;
-                        $lines++;
-                }
-        }
-        close (FILE);   
+       while (<FILE>)
+       {
+               if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=.*)$/) {
+                       $log[$lines] = $_;
+                       $lines++;
+               }
+       }
+       close (FILE);
 }
 
 $skip=0;
 if ($multifile) {
-        $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);
+       }
 }
 
 my $MODNAME="fwlogs";
@@ -217,9 +217,9 @@ my $MODNAME="fwlogs";
 &Header::openbigbox('100%', 'left', '', $errormessage);
 
 if ($errormessage) {
-        &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
-        print "<font class='base'>$errormessage&nbsp;</font>\n";
-        &Header::closebox();
+       &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
+       print "<font class='base'>$errormessage&nbsp;</font>\n";
+       &Header::closebox();
 }
 
 &Header::openbox('100%', 'left', "$Lang::tr{'settings'}");
@@ -228,33 +228,33 @@ print <<END
 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
 <table width='100%'>
 <tr>
-        <td width='10%' class='base'>$Lang::tr{'month'}:&nbsp;</td>
-        <td width='10%'>
-        <select name='MONTH'>
+       <td width='10%' class='base'>$Lang::tr{'month'}:&nbsp;</td>
+       <td width='10%'>
+       <select name='MONTH'>
 END
 ;
 my $month;
 for ($month = 0; $month < 12; $month++)
 {
-        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 <<END
-        </select>
-        </td>
-        <td width='10%' class='base' align='right'>&nbsp;$Lang::tr{'day'}:&nbsp;</td>
-        <td width='40%'>
-        <select name='DAY'>
+       </select>
+       </td>
+       <td width='10%' class='base' align='right'>&nbsp;$Lang::tr{'day'}:&nbsp;</td>
+       <td width='40%'>
+       <select name='DAY'>
 END
 ;
 for ($day = 1; $day <= 31; $day++) 
 {
-        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( $cgiparams{'pienumber'} != 0){$pienumber=$cgiparams{'pienumber'};}
@@ -291,11 +291,11 @@ if ($pienumber == -1 || $pienumber > $lines || $sortcolumn == 2) { $pienumber =
 $lines = 0;
 foreach $_ (@log)
 {
-  if($_ =~  /DPT\=([\d\.]+)/){
-    $tabjc{$1} = $tabjc{$1} + 1 ;
-    if(($tabjc{$1} == 1) && ($lines < $pienumber)) { $lines = $lines + 1; }
-    $linesjc++;
-  }
+       if($_ =~  /DPT\=([\d\.]+)/){
+               $tabjc{$1} = $tabjc{$1} + 1 ;
+               if(($tabjc{$1} == 1) && ($lines < $pienumber)) { $lines = $lines + 1; }
+               $linesjc++;
+       }
 }
 
 $pienumber = $lines;
@@ -317,11 +317,11 @@ my @tabjc2;
 
 if ($sortcolumn == 1)
 {
-        @tabjc2 = sort { $b <=> $a } values (%tabjc);
+       @tabjc2 = sort { $b <=> $a } values (%tabjc);
 }
 else
 {
-        @tabjc2 = sort { $a <=> $b } keys (%tabjc);
+       @tabjc2 = sort { $a <=> $b } keys (%tabjc);
 }
 
 my $color=10;
@@ -338,17 +338,17 @@ my $v;
 
 if ($sortcolumn == 1)
 {
-        for ($v=0;$v<$pienumber;$v++){
-          findkey($tabjc2[$v]);
-        }
+       for ($v=0;$v<$pienumber;$v++){
+               findkey($tabjc2[$v]);
+       }
 }
 else
 {
-        foreach $v (@tabjc2) {
-          $key[$indice] = $v;
-          $value[$indice] = $tabjc{$v};
-          $indice++;
-        }
+       foreach $v (@tabjc2) {
+               $key[$indice] = $v;
+               $value[$indice] = $tabjc{$v};
+               $indice++;
+       }
 }
 
 my @ports;
@@ -361,15 +361,15 @@ 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 $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);
@@ -381,28 +381,28 @@ my %mainsettings = ();
 &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-port*.png");
-        unlink(@filenames);
-        my $imagerandom = rand(1000000);
-        my $imagename = "/srv/web/ipfire/html/graphs/fwlog-port$imagerandom.png";
-        open(FILE,">$imagename");
-        print FILE $myimage->png;
-        close(FILE);
-        #####################################################
-        print "<div style='text-align:center'>";
-        print "<img src='/graphs/fwlog-port$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-port*.png");
+       unlink(@filenames);
+       my $imagerandom = rand(1000000);
+       my $imagename = "/srv/web/ipfire/html/graphs/fwlog-port$imagerandom.png";
+       open(FILE,">$imagename");
+       print FILE $myimage->png;
+       close(FILE);
+       #####################################################
+       print "<div style='text-align:center'>";
+       print "<img src='/graphs/fwlog-port$imagerandom.png'>";
+       print "</div>";
 }
 
 print <<END
@@ -425,45 +425,44 @@ my $col="";
 
 for($s=0;$s<$lines;$s++)
 {
-  $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>";
-
-  $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='$Lang::tr{'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>";
+       $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>";
+
+       $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='$Lang::tr{'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{
-  # 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{'otherport'}</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{'otherport'}</td>
+               <td align='center' $col>$dif</td>
+               <td align='center' $col>$percent</td>
+               </tr>
 END
-;
-}
+               ;
+       }
 }
 print <<END
 </table>
@@ -475,20 +474,20 @@ END
 &Header::closepage();
 
 sub findkey {
-  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;
+               }
+       }
 }
 
 sub checkversion {
-    #Automatic Updates is disabled
-    return "0","0";
+               #Automatic Updates is disabled
+               return "0","0";
 }
 
index 27e76971a3e6059af6502fb4844265d2e8f57fcd..cd97f878075b30de5b32376d3fccdcbb056303cf 100644 (file)
@@ -69,60 +69,60 @@ if (!($cgiparams{'MONTH'} =~ /^(0|1|2|3|4|5|6|7|8|9|10|11)$/) ||
 }
 elsif($cgiparams{'ACTION'} eq '>>')
 {
-        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];
 }
 elsif($cgiparams{'ACTION'} eq '<<')
 {
-        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];
 }
 
 if (($cgiparams{'DAY'} ne $now[3]) || ($cgiparams{'MONTH'} ne $now[4]))
 {
-        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;
+               }
+       }
 }
 my $datediff=0;
 my $dowd=0;
 my $multifile=0;
 if ($tdoy ne $doy) {
-        $datediff=int(($doy-$tdoy)/7);
-        $dowd=($doy-$tdoy)%7;
-        if (($dow-$dowd)<1) {
-                $datediff=$datediff+1;
-        }
-        if (($dow-$dowd)==0) {
-                $multifile=1;
-        }
+       $datediff=int(($doy-$tdoy)/7);
+       $dowd=($doy-$tdoy)%7;
+       if (($dow-$dowd)<1) {
+               $datediff=$datediff+1;
+       }
+       if (($dow-$dowd)==0) {
+               $multifile=1;
+       }
 }
 
 my $monthstr = $shortmonths[$cgiparams{'MONTH'}];
@@ -138,16 +138,16 @@ else {
 my $skip=0;
 my $filestr='';
 if ($datediff==0) {
-        $filestr="/var/log/messages";
+       $filestr="/var/log/messages";
 } else {
-       $filestr="/var/log/messages.$datediff";
-       $filestr = "$filestr.gz" if -f "$filestr.gz";
+       $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
 }
 my $lines = 0;
 my @log=();
@@ -156,78 +156,77 @@ my $gi = Geo::IP::PurePerl->new();
 
 if (!$skip)
 {
-    while (<FILE>)
-    {
-         # First check whether valid log line (date, day)
-          if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=.*)$/) {
-           # If ipv6 uses bridge, then use PHYSIN otherwise use IN
-            if    (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(PHYSIN=.*)$/) {}
-            elsif (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=.*)$/) {}
-            my $packet  = $2;
-            my $iface   = '';
-            my $srcaddr = '';
-            # If ipv6 uses bridge, use PHYSIN otherwise IN
-            if ($packet =~ /PHYSIN=(\w+)/) { $iface = $1; } elsif ($packet =~ /IN=(\w+)/) { $iface = $1; }
-            # Extract ipv4 and ipv6 addresses
-            if (($packet =~ /SRC\=(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($packet =~ /SRC\=(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) {
-              $srcaddr = $1; 
-            };
-
-            if($iface eq $country) {
-                # iface matches country code
-                $log[$lines] = $_;
-                $lines++;
-            }
-            elsif($srcaddr ne '') {
-                # or srcaddr matches country code
-                my $ccode = $gi->country_code_by_name($srcaddr);
-                if($ccode eq uc($country)){
-                    $log[$lines] = $_;
-                    $lines++;
-                }
-            }
-          }
+       while (<FILE>) {
+               # First check whether valid log line (date, day)
+               if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=.*)$/) {
+                       # If ipv6 uses bridge, then use PHYSIN otherwise use IN
+                       if    (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(PHYSIN=.*)$/) {}
+                       elsif (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=.*)$/) {}
+                       my $packet      = $2;
+                       my $iface = '';
+                       my $srcaddr = '';
+                       # If ipv6 uses bridge, use PHYSIN otherwise IN
+                       if ($packet =~ /PHYSIN=(\w+)/) { $iface = $1; } elsif ($packet =~ /IN=(\w+)/) { $iface = $1; }
+                       # Extract ipv4 and ipv6 addresses
+                       if (($packet =~ /SRC\=(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($packet =~ /SRC\=(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) {
+                               $srcaddr = $1; 
+                       }
+
+                       if($iface eq $country) {
+                               # iface matches country code
+                               $log[$lines] = $_;
+                               $lines++;
+                       }
+                       elsif($srcaddr ne '') {
+                               # or srcaddr matches country code
+                               my $ccode = $gi->country_code_by_name($srcaddr);
+                               if($ccode eq uc($country)){
+                                       $log[$lines] = $_;
+                                       $lines++;
+                               }
+                       }
+               }
        }
        close (FILE);   
 }
 
 $skip=0;
 if ($multifile) {
-        $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) {
+       $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>) {
-                  # Check if valid log line (date, day)
-                 if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=.*)$/) {
-                    my  $iface = '';
-                    # If ipv6 uses bridge, then use PHYSIN otherwise IN
-                    if ($_ =~ /PHYSIN=(\w+)/) { $iface = $1; } elsif ($_ =~ /IN=(\w+)/) { $iface = $1; }
-
-                    if($iface eq $country) {
-                      # iface matches country code
-                      $log[$lines] = $_;
-                      $lines++;
-                    }
-                    # extract ipv4 and ipv6 address
-                    elsif (($_ =~ /SRC\=(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($_ =~ /SRC\=(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) {
-                      my $srcaddr=$1;
-                      my $ccode = $gi->country_code_by_name($srcaddr);
-                      if($ccode eq uc($country)){
-                        # or srcaddr matches country code
-                        $log[$lines] = $_;
-                        $lines++;
-                      }
-                    }
-                 }
+                       # Check if valid log line (date, day)
+                       if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=.*)$/) {
+                               my $iface = '';
+                               # If ipv6 uses bridge, then use PHYSIN otherwise IN
+                               if ($_ =~ /PHYSIN=(\w+)/) { $iface = $1; } elsif ($_ =~ /IN=(\w+)/) { $iface = $1; }
+
+                               if($iface eq $country) {
+                                       # iface matches country code
+                                       $log[$lines] = $_;
+                                       $lines++;
+                               }
+                               # extract ipv4 and ipv6 address
+                               elsif (($_ =~ /SRC\=(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($_ =~ /SRC\=(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) {
+                                       my $srcaddr=$1;
+                                       my $ccode = $gi->country_code_by_name($srcaddr);
+                                       if($ccode eq uc($country)){
+                                               # or srcaddr matches country code
+                                               $log[$lines] = $_;
+                                               $lines++;
+                                       }
+                               }
+                       }
                }
                close (FILE);
        }
@@ -259,7 +258,8 @@ for ($month = 0; $month < 12; $month++)
 {
        print "\t<option ";
        if ($month == $cgiparams{'MONTH'}) {
-               print "selected='selected' "; }
+               print "selected='selected' "; 
+       }
        print "value='$month'>$longmonths[$month]</option>\n";
 }
 print <<END
@@ -296,7 +296,8 @@ END
 print "<p><b>$Lang::tr{'firewall hits'} $longmonthstr $daystr: $lines</b></p>";
 
 if ($start == -1) {
-        $start = $lines - ${Header::viewsize}; }
+       $start = $lines - ${Header::viewsize}; 
+}
 if ($start >= $lines - ${Header::viewsize}) { $start = $lines - ${Header::viewsize}; };
 if ($start < 0) { $start = 0; }
 
@@ -331,78 +332,80 @@ if ($logsettings{'LOGVIEW_REVERSE'} eq 'on') { @slice = reverse @slice; }
 $lines = 0;
 foreach $_ (@slice)
 {
-  $a = $_;
-  # If ipv6 uses bridge, use PHYSIN otherwise use IN
-  if    (/^... (..) (..:..:..) [\w\-]+ kernel:(.*)(PHYSIN=.*)$/) {}
-  elsif (/^... (..) (..:..:..) [\w\-]+ kernel:(.*)(IN=.*)$/) {};
-  my $packet = $4;
-  my $iface = ''; 
-  # If ipv6 uses bridge, use PHYSIN otherwise use IN
-  if ($packet =~ /PHYSIN=(\w+)/) { $iface = $1; } elsif ($packet =~ /IN=(\w+)/) { $iface = $1; }  
-  if ( $1 =~ /2./ ){ $iface=""; }
-  my $srcaddr = '';
-  # Extract ipv4 and ipv6 addresses
-  if (($packet =~ /SRC\=(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($packet =~ /SRC\=(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) {
-    $srcaddr = $1;
-  };
-
-  if($iface eq $country || $srcaddr ne '') {
-    my $ccode='';
-    if($iface ne $country) {
-      $ccode = $gi->country_code_by_name($srcaddr);
-    }
-    if($iface eq $country || $ccode eq uc($country)) {
-      my $chain = '';
-      my $in = '-'; my $out = '-';
-      my $srcaddr = ''; my $dstaddr = '';
-      my $protostr = '';
-      my $srcport = ''; my $dstport = '';
-
-      # If ipv6 uses bridge, the use PHYSIN otherwise use IN
-      if    ($_ =~ /(^.* ..:..:..) [\w\-]+ kernel:(.*)(IN=.*)(PHYSIN=.*)$/) {}
-      elsif ($_ =~ /(^.* ..:..:..) [\w\-]+ kernel:(.*)(IN=.*)$/) {}
-      my $timestamp = $1; my $chain = $2; my $packet = $3;
-      $timestamp =~ /(...) (..) (..:..:..)/;
-      my $month = $1; my $day = $2; my $time = $3;
-
-      # If ipv6 uses bridge, use PHYSIN and PHYSOUT, otherwise use IN and OUT
-      if ($a =~ /PHYSIN=(\w+)/)  { $iface = $1; } elsif ($a =~ /IN=(\w+)/)  { $iface = $1; }
-      if ($a =~ /PHYSOUT=(\w+)/) { $out = $1; }   elsif ($a =~ /OUT=(\w+)/) { $out = $1; }
-      # Extract ipv4 and ipv6 addresses
-      if (($a =~ /SRC\=(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($a =~ /SRC\=(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { $srcaddr = $1; }
-      if (($a =~ /DST\=(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($a =~ /DST\=(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { $dstaddr = $1; }
-      if ($a =~ /PROTO\=(\w+)/) { $protostr = $1; }
-      my $protostrlc = lc($protostr);
-      if ($a =~  /SPT\=([\d\.]+)/){ $srcport = $1; }
-      if ($a =~  /DPT\=([\d\.]+)/){ $dstport = $1; }
-
-      if ($lines % 2) {
-        print "<tr bgcolor='${Header::table1colour}'>\n"; }
-      else {
-        print "<tr bgcolor='${Header::table2colour}'>\n"; }
-      print <<END
-      <td align='center'>$time</td>
-      <td align='center'>$chain</td>
-      <td align='center'>$iface</td>
-      <td align='center'>$protostr</td>
-      <td align='center'>
-      <table width='100%' cellpadding='0' cellspacing='0'><tr>
-      <td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$srcaddr'>$srcaddr</a></td>
-      </tr></table>
-      </td>
-      <td align='center'>$srcport</td>
-      <td align='center'>
-      <table width='100%' cellpadding='0' cellspacing='0'><tr>
-      <td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$dstaddr'>$dstaddr</a></td>
-      </tr></table>
-      </td>
-      <td align='center'>$dstport</td>
-      </tr>
+       $a = $_;
+       # If ipv6 uses bridge, use PHYSIN otherwise use IN
+       if    (/^... (..) (..:..:..) [\w\-]+ kernel:(.*)(PHYSIN=.*)$/) {}
+       elsif (/^... (..) (..:..:..) [\w\-]+ kernel:(.*)(IN=.*)$/) {};
+       my $packet = $4;
+       my $iface = ''; 
+       # If ipv6 uses bridge, use PHYSIN otherwise use IN
+       if ($packet =~ /PHYSIN=(\w+)/) { $iface = $1; } elsif ($packet =~ /IN=(\w+)/) { $iface = $1; }  
+       if ( $1 =~ /2./ ){ $iface=""; }
+       my $srcaddr = '';
+       # Extract ipv4 and ipv6 addresses
+       if (($packet =~ /SRC\=(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($packet =~ /SRC\=(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) {
+               $srcaddr = $1;
+       };
+
+       if($iface eq $country || $srcaddr ne '') {
+               my $ccode='';
+               if($iface ne $country) {
+                       $ccode = $gi->country_code_by_name($srcaddr);
+               }
+               if($iface eq $country || $ccode eq uc($country)) {
+                       my $chain = '';
+                       my $in = '-'; my $out = '-';
+                       my $srcaddr = ''; my $dstaddr = '';
+                       my $protostr = '';
+                       my $srcport = ''; my $dstport = '';
+
+                       # If ipv6 uses bridge, the use PHYSIN otherwise use IN
+                       if    ($_ =~ /(^.* ..:..:..) [\w\-]+ kernel:(.*)(IN=.*)(PHYSIN=.*)$/) {}
+                       elsif ($_ =~ /(^.* ..:..:..) [\w\-]+ kernel:(.*)(IN=.*)$/) {}
+                       my $timestamp = $1; my $chain = $2; my $packet = $3;
+                       $timestamp =~ /(...) (..) (..:..:..)/;
+                       my $month = $1; my $day = $2; my $time = $3;
+
+                       # If ipv6 uses bridge, use PHYSIN and PHYSOUT, otherwise use IN and OUT
+                       if ($a =~ /PHYSIN=(\w+)/)  { $iface = $1; } elsif ($a =~ /IN=(\w+)/)  { $iface = $1; }
+                       if ($a =~ /PHYSOUT=(\w+)/) { $out = $1; }   elsif ($a =~ /OUT=(\w+)/) { $out = $1; }
+                       # Extract ipv4 and ipv6 addresses
+                       if (($a =~ /SRC\=(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($a =~ /SRC\=(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { $srcaddr = $1; }
+                       if (($a =~ /DST\=(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($a =~ /DST\=(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { $dstaddr = $1; }
+                       if ($a =~ /PROTO\=(\w+)/) { $protostr = $1; }
+                       my $protostrlc = lc($protostr);
+                       if ($a =~ /SPT\=([\d\.]+)/){ $srcport = $1; }
+                       if ($a =~ /DPT\=([\d\.]+)/){ $dstport = $1; }
+
+                       if ($lines % 2) {
+                               print "<tr bgcolor='${Header::table1colour}'>\n"; 
+                       }
+                       else {
+                               print "<tr bgcolor='${Header::table2colour}'>\n"; 
+                       }
+                       print <<END
+                       <td align='center'>$time</td>
+                       <td align='center'>$chain</td>
+                       <td align='center'>$iface</td>
+                       <td align='center'>$protostr</td>
+                       <td align='center'>
+                       <table width='100%' cellpadding='0' cellspacing='0'><tr>
+                       <td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$srcaddr'>$srcaddr</a></td>
+                       </tr></table>
+                       </td>
+                       <td align='center'>$srcport</td>
+                       <td align='center'>
+                       <table width='100%' cellpadding='0' cellspacing='0'><tr>
+                       <td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$dstaddr'>$dstaddr</a></td>
+                       </tr></table>
+                       </td>
+                       <td align='center'>$dstport</td>
+                       </tr>
 END
-       ;
-      $lines++;
-    }
-  }
+                       ;
+                       $lines++;
+               }
+       }
 }
 
 print <<END
@@ -420,30 +423,34 @@ END
 
 sub oldernewer
 {
-  print <<END
-  <table width='100%'>
-  <tr>
+       print <<END
+       <table width='100%'>
+       <tr>
 END
-;
+       ;
 
-  print "<td align='center' width='50%'>";
-  if ($prev != -1) {
-    print "<a href='/cgi-bin/logs.cgi/showrequestfromcountry.dat?$prev,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{country}'>$Lang::tr{'older'}</a>"; }
-  else {
-    print "$Lang::tr{'older'}"; }
-  print "</td>\n";
+       print "<td align='center' width='50%'>";
+       if ($prev != -1) {
+               print "<a href='/cgi-bin/logs.cgi/showrequestfromcountry.dat?$prev,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{country}'>$Lang::tr{'older'}</a>"; 
+       }
+       else {
+               print "$Lang::tr{'older'}"; 
+       }
+       print "</td>\n";
 
-  print "<td align='center' width='50%'>";
-  if ($next != -1) {
-    print "<a href='/cgi-bin/logs.cgi/showrequestfromcountry.dat?$next,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{country}'>$Lang::tr{'newer'}</a>"; }
-  else {
-   print "$Lang::tr{'newer'}"; }
-  print "</td>\n";
+       print "<td align='center' width='50%'>";
+       if ($next != -1) {
+               print "<a href='/cgi-bin/logs.cgi/showrequestfromcountry.dat?$next,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{country}'>$Lang::tr{'newer'}</a>"; 
+       }
+       else {
+               print "$Lang::tr{'newer'}"; 
+       }
 
-print <<END
-  </tr>
-  </table>
+       print "</td>\n";
+       print <<END
+       </tr>
+       </table>
 END
-;
+       ;
 }
 
index d7d1ace912479c33863d96be4767c2ebc51b1522..154fa40309dcc36d1ebb45bd0622757fdb64677c 100644 (file)
@@ -66,60 +66,60 @@ if (!($cgiparams{'MONTH'} =~ /^(0|1|2|3|4|5|6|7|8|9|10|11)$/) ||
 }
 elsif($cgiparams{'ACTION'} eq '>>')
 {
-        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];
 }
 elsif($cgiparams{'ACTION'} eq '<<')
 {
-        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];
 }
 
 if (($cgiparams{'DAY'} ne $now[3]) || ($cgiparams{'MONTH'} ne $now[4]))
 {
-        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;
+               }
+       }
 }
 my $datediff=0;
 my $dowd=0;
 my $multifile=0;
 if ($tdoy ne $doy) {
-        $datediff=int(($doy-$tdoy)/7);
-        $dowd=($doy-$tdoy)%7;
-        if (($dow-$dowd)<1) {
-                $datediff=$datediff+1;
-        }
-        if (($dow-$dowd)==0) {
-                $multifile=1;
-        }
+       $datediff=int(($doy-$tdoy)/7);
+       $dowd=($doy-$tdoy)%7;
+       if (($dow-$dowd)<1) {
+               $datediff=$datediff+1;
+       }
+       if (($dow-$dowd)==0) {
+               $multifile=1;
+       }
 }
 
 my $monthstr = $shortmonths[$cgiparams{'MONTH'}];
@@ -135,16 +135,16 @@ else {
 my $skip=0;
 my $filestr='';
 if ($datediff==0) {
-        $filestr="/var/log/messages";
+       $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;
-        # 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
 }
 my $lines = 0;
 my @log=();
@@ -152,15 +152,14 @@ my $ip = $cgiparams{ip};
 
 if (!$skip)
 {
-        while (<FILE>)
-        {
+       while (<FILE>) {
                if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=.*)$/) {
-                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})/)) {
-                  if($1 eq $ip){
-                       $log[$lines] = $_;
-                       $lines++;
-                  }
-                }
+                       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})/)) {
+                               if($1 eq $ip){
+                                       $log[$lines] = $_;
+                                       $lines++;
+                               }
+                       }
                }
        }
        close (FILE);   
@@ -168,26 +167,26 @@ if (!$skip)
 
 $skip=0;
 if ($multifile) {
-        $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) {
+       $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=.*)$/) {
-                          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})/)) {
-                            if($1 eq $ip){
-                               $log[$lines] = $_;
-                               $lines++;
-                            }
-                          }
+                       if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=.*)$/) {
+                               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})/)) {
+                                       if($1 eq $ip){
+                                               $log[$lines] = $_;
+                                               $lines++;
+                                       }
+                               }
                        }
                }
                close (FILE);
@@ -257,7 +256,8 @@ END
 print "<p><b>$Lang::tr{'firewall hits'} $longmonthstr $daystr: $lines</b></p>";
 
 if ($start == -1) {
-        $start = $lines - ${Header::viewsize}; }
+       $start = $lines - ${Header::viewsize}; 
+}
 if ($start >= $lines - ${Header::viewsize}) { $start = $lines - ${Header::viewsize}; };
 if ($start < 0) { $start = 0; }
 
@@ -290,63 +290,64 @@ my @slice = splice(@log, $start, ${Header::viewsize});
 if ($logsettings{'LOGVIEW_REVERSE'} eq 'on') { @slice = reverse @slice; }
 
 $lines = 0;
-foreach $_ (@slice)
-{
-  $a = $_;
-  # Check whether valid 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})/)) {
-    if($1 eq $ip){
-       my $chain = '';
-       my $in = '-'; my $out = '-';
-       my $srcaddr = ''; my $dstaddr = '';
-       my $protostr = '';
-       my $srcport = ''; my $dstport = '';
-
-       # If ipv6 uses bridge, the use PHYSIN, otherwise use IN
-        if    ($_ =~ /(^.* ..:..:..) [\w\-]+ kernel:(.*)(IN=.*)(PHYSIN=.*)$/) {}
-        elsif ($_ =~ /(^.* ..:..:..) [\w\-]+ kernel:(.*)(IN=.*)$/) {}
-       my $timestamp = $1; my $chain = $2; my $packet = $3;
-       $timestamp =~ /(...) (..) (..:..:..)/;
-       my $month = $1; my $day = $2; my $time = $3;
-
-        # If ipv6 uses bridge, the use PHYSIN and PHYSOUT, otherwise use IN and OUT
-        if ($a =~ /PHYSIN=(\w+)/)  { $iface = $1; } elsif ($a =~ /IN=(\w+)/)  { $iface = $1; }
-        if ($a =~ /PHYSOUT=(\w+)/) { $out = $1; }   elsif ($a =~ /OUT=(\w+)/) { $out = $1; }
-        # Detect ipv4 and ipv6 addresses
-       if (($a =~ /SRC\=(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($a =~ /SRC\=(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { $srcaddr = $1; }
-       if (($a =~ /DST\=(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($a =~ /DST\=(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { $dstaddr = $1; }
-       if ($a =~ /PROTO\=(\w+)/) { $protostr = $1; }
-       my $protostrlc = lc($protostr);
-       if ($a =~  /SPT\=([\d\.]+)/){ $srcport = $1; }
-       if ($a =~  /DPT\=([\d\.]+)/){ $dstport = $1; }
-
-       if ($lines % 2) {
-               print "<tr bgcolor='${Header::table1colour}'>\n"; }
-       else {
-               print "<tr bgcolor='${Header::table2colour}'>\n"; }
-       print <<END
-       <td align='center'>$time</td>
-       <td align='center'>$chain</td>
-       <td align='center'>$iface</td>
-       <td align='center'>$protostr</td>
-       <td align='center'>
-       <table width='100%' cellpadding='0' cellspacing='0'><tr>
-       <td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$srcaddr'>$srcaddr</a></td>
-       </tr></table>
-       </td>
-       <td align='center'>$srcport</td>
-       <td align='center'>
-       <table width='100%' cellpadding='0' cellspacing='0'><tr>
-       <td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$dstaddr'>$dstaddr</a></td>
-       </tr></table>
-       </td>
-       <td align='center'>$dstport</td>
-</tr>
+foreach $_ (@slice) {
+       $a = $_;
+       # Check whether valid 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})/)) {
+               if($1 eq $ip) {
+                       my $chain = '';
+                       my $in = '-'; my $out = '-';
+                       my $srcaddr = ''; my $dstaddr = '';
+                       my $protostr = '';
+                       my $srcport = ''; my $dstport = '';
+
+                       # If ipv6 uses bridge, the use PHYSIN, otherwise use IN
+                       if    ($_ =~ /(^.* ..:..:..) [\w\-]+ kernel:(.*)(IN=.*)(PHYSIN=.*)$/) {}
+                       elsif ($_ =~ /(^.* ..:..:..) [\w\-]+ kernel:(.*)(IN=.*)$/) {}
+                       my $timestamp = $1; my $chain = $2; my $packet = $3;
+                       $timestamp =~ /(...) (..) (..:..:..)/;
+                       my $month = $1; my $day = $2; my $time = $3;
+
+                       # If ipv6 uses bridge, the use PHYSIN and PHYSOUT, otherwise use IN and OUT
+                       if ($a =~ /PHYSIN=(\w+)/)  { $iface = $1; } elsif ($a =~ /IN=(\w+)/)  { $iface = $1; }
+                       if ($a =~ /PHYSOUT=(\w+)/) { $out = $1; }   elsif ($a =~ /OUT=(\w+)/) { $out = $1; }
+                       # Detect ipv4 and ipv6 addresses
+                       if (($a =~ /SRC\=(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($a =~ /SRC\=(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { $srcaddr = $1; }
+                       if (($a =~ /DST\=(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($a =~ /DST\=(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { $dstaddr = $1; }
+                       if ($a =~ /PROTO\=(\w+)/) { $protostr = $1; }
+                       my $protostrlc = lc($protostr);
+                       if ($a =~  /SPT\=([\d\.]+)/){ $srcport = $1; }
+                       if ($a =~  /DPT\=([\d\.]+)/){ $dstport = $1; }
+
+                       if ($lines % 2) {
+                               print "<tr bgcolor='${Header::table1colour}'>\n"; 
+                       }
+                       else {
+                               print "<tr bgcolor='${Header::table2colour}'>\n"; 
+                       }
+                       print <<END
+                       <td align='center'>$time</td>
+                       <td align='center'>$chain</td>
+                       <td align='center'>$iface</td>
+                       <td align='center'>$protostr</td>
+                       <td align='center'>
+                       <table width='100%' cellpadding='0' cellspacing='0'><tr>
+                       <td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$srcaddr'>$srcaddr</a></td>
+                       </tr></table>
+                       </td>
+                       <td align='center'>$srcport</td>
+                       <td align='center'>
+                       <table width='100%' cellpadding='0' cellspacing='0'><tr>
+                       <td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$dstaddr'>$dstaddr</a></td>
+                       </tr></table>
+                       </td>
+                       <td align='center'>$dstport</td>
+                       </tr>
 END
-       ;
-       $lines++;
-    }
-  }
+                       ;
+                       $lines++;
+               }
+       }
 }
 
 print <<END
@@ -364,29 +365,33 @@ END
 
 sub oldernewer
 {
-print <<END
-<table width='100%'>
-<tr>
+       print <<END
+       <table width='100%'>
+       <tr>
 END
-;
+       ;
 
-print "<td align='center' width='50%'>";
-if ($prev != -1) {
-       print "<a href='/cgi-bin/logs.cgi/showrequestfromip.dat?$prev,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{ip}'>$Lang::tr{'older'}</a>"; }
-else {
-       print "$Lang::tr{'older'}"; }
-print "</td>\n";
+       print "<td align='center' width='50%'>";
+       if ($prev != -1) {
+               print "<a href='/cgi-bin/logs.cgi/showrequestfromip.dat?$prev,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{ip}'>$Lang::tr{'older'}</a>"; 
+       }
+       else {
+               print "$Lang::tr{'older'}"; 
+       }
+       print "</td>\n";
 
-print "<td align='center' width='50%'>";
-if ($next != -1) {
-       print "<a href='/cgi-bin/logs.cgi/showrequestfromip.dat?$next,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{ip}'>$Lang::tr{'newer'}</a>"; }
-else {
-       print "$Lang::tr{'newer'}"; }
-print "</td>\n";
+       print "<td align='center' width='50%'>";
+       if ($next != -1) {
+               print "<a href='/cgi-bin/logs.cgi/showrequestfromip.dat?$next,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{ip}'>$Lang::tr{'newer'}</a>"; 
+       }
+       else {
+               print "$Lang::tr{'newer'}"; 
+       }
+       print "</td>\n";
 
-print <<END
-</tr>
-</table>
+       print <<END
+       </tr>
+       </table>
 END
-;
+       ;
 }
index 6f5f63bfbf232c470aff51ee658c3a8367eef95c..e1f00aed8fb26fdd222db0c68b576c44ca727a2a 100644 (file)
@@ -73,60 +73,60 @@ if (!($cgiparams{'MONTH'} =~ /^(0|1|2|3|4|5|6|7|8|9|10|11)$/) ||
 }
 elsif($cgiparams{'ACTION'} eq '>>')
 {
-        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];
 }
 elsif($cgiparams{'ACTION'} eq '<<')
 {
-        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];
 }
 
 if (($cgiparams{'DAY'} ne $now[3]) || ($cgiparams{'MONTH'} ne $now[4]))
 {
-        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;
+               }
+       }
 }
 my $datediff=0;
 my $dowd=0;
 my $multifile=0;
 if ($tdoy ne $doy) {
-        $datediff=int(($doy-$tdoy)/7);
-        $dowd=($doy-$tdoy)%7;
-        if (($dow-$dowd)<1) {
-                $datediff=$datediff+1;
-        }
-        if (($dow-$dowd)==0) {
-                $multifile=1;
-        }
+       $datediff=int(($doy-$tdoy)/7);
+       $dowd=($doy-$tdoy)%7;
+       if (($dow-$dowd)<1) {
+               $datediff=$datediff+1;
+       }
+       if (($dow-$dowd)==0) {
+               $multifile=1;
+       }
 }
 
 my $monthstr = $shortmonths[$cgiparams{'MONTH'}];
@@ -142,16 +142,16 @@ else {
 my $skip=0;
 my $filestr='';
 if ($datediff==0) {
-        $filestr="/var/log/messages";
+       $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;
-        # 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
 }
 my $lines = 0;
 my @log=();
@@ -159,15 +159,15 @@ my $port = $cgiparams{port};
 
 if (!$skip)
 {
-        while (<FILE>)
-        {
-               if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=.*)$/) {
-                if($_ =~  /DPT\=([\d\.]+)/){
-                  if($1 eq $port){
-                       $log[$lines] = $_;
-                       $lines++;
-                  }
-                }
+       while (<FILE>)
+       {
+               if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=.*)$/) {
+                       if($_ =~  /DPT\=([\d\.]+)/){
+                               if($1 eq $port){
+                                       $log[$lines] = $_;
+                                       $lines++;
+                               }
+                       }
                }
        }
        close (FILE);   
@@ -175,26 +175,26 @@ if (!$skip)
 
 $skip=0;
 if ($multifile) {
-        $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) {
+       $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=.*)$/) {
-                       if($_ =~  /DPT\=([\d\.]+)/){
-                         if($1 eq $port){
-                               $log[$lines] = $_;
-                               $lines++;
-                         }
-                       }
+                       if (/(^${monthstr} ${daystr} ..:..:..) [\w\-]+ kernel:.*(IN=.*)$/) {
+                               if($_ =~  /DPT\=([\d\.]+)/){
+                                       if($1 eq $port){
+                                               $log[$lines] = $_;
+                                               $lines++;
+                                       }
+                               }
                        }
                }
                close (FILE);
@@ -264,7 +264,8 @@ END
 print "<p><b>$Lang::tr{'firewall hits'} $longmonthstr $daystr: $lines</b></p>";
 
 if ($start == -1) {
-        $start = $lines - ${Header::viewsize}; }
+       $start = $lines - ${Header::viewsize}; 
+}
 if ($start >= $lines - ${Header::viewsize}) { $start = $lines - ${Header::viewsize}; };
 if ($start < 0) { $start = 0; }
 
@@ -298,60 +299,65 @@ if ($logsettings{'LOGVIEW_REVERSE'} eq 'on') { @slice = reverse @slice; }
 $lines = 0;
 foreach $_ (@slice)
 {
-  $a = $_;
-  if($_ =~  /DPT\=([\d\.]+)/){
-    if($1 eq $port){
-       my $chain = '';
-       my $in = '-'; my $out = '-';
-       my $srcaddr = ''; my $dstaddr = '';
-       my $protostr = '';
-       my $srcport = ''; my $dstport = '';
-
-        # If ipv6 uses bridge, the use PHYSIN, otherwise use IN
-       if    ($_ =~ /(^.* ..:..:..) [\w\-]+ kernel:(.*)(IN=.*)(PHYSIN=.*)$/) {}
-        elsif ($_ =~ /(^.* ..:..:..) [\w\-]+ kernel:(.*)(IN=.*)$/) {}
-       my $timestamp = $1; my $chain = $2; my $packet = $3;
-       $timestamp =~ /(...) (..) (..:..:..)/;
-       my $month = $1; my $day = $2; my $time = $3; my $iface;
-
-        # If ipv6 uses bridge, the use PHYSIN and PHYSOUT, otherwise use IN and OUT
-       if ($a =~ /PHYSIN\=(\w+)/)  { $iface = $1; } elsif ($a =~ /IN\=(\w+)/)  { $iface = $1; }
-        if ($a =~ /PHYSOUT\=(\w+)/) { $out = $1; }   elsif ($a =~ /OUT\=(\w+)/) { $out = $1; }
-       # Detect ipv4 and ipv6 addresses
-       if (($a =~ /SRC\=(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($a =~ /SRC\=(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { $srcaddr = $1; }
-       if (($a =~ /DST\=(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($a =~ /DST\=(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { $dstaddr = $1; }
-       if ($a =~ /PROTO\=(\w+)/) { $protostr = $1; }
-       my $protostrlc = lc($protostr);
-       if ($a =~  /SPT\=([\d\.]+)/){ $srcport = $1; }
-       if ($a =~  /DPT\=([\d\.]+)/){ $dstport = $1; }
-
-       if ($lines % 2) {
-               print "<tr bgcolor='${Header::table1colour}'>\n"; }
-       else {
-               print "<tr bgcolor='${Header::table2colour}'>\n"; }
-       print <<END
-       <td align='center'>$time</td>
-       <td align='center'>$chain</td>
-       <td align='center'>$iface</td>
-       <td align='center'>$protostr</td>
-       <td align='center'>
-       <table width='100%' cellpadding='0' cellspacing='0'><tr>
-       <td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$srcaddr'>$srcaddr</a></td>
-       </tr></table>
-       </td>
-       <td align='center'>$srcport</td>
-       <td align='center'>
-       <table width='100%' cellpadding='0' cellspacing='0'><tr>
-       <td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$dstaddr'>$dstaddr</a></td>
-       </tr></table>
-       </td>
-       <td align='center'>$dstport</td>
-</tr>
+       $a = $_;
+       if($_ =~  /DPT\=([\d\.]+)/){
+               if($1 eq $port){
+                       my $chain = '';
+                       my $in = '-';
+                       my $out = '-';
+                       my $srcaddr = '';
+                       my $dstaddr = '';
+                       my $protostr = '';
+                       my $srcport = '';
+                       my $dstport = '';
+
+                       # If ipv6 uses bridge, the use PHYSIN, otherwise use IN
+                       if    ($_ =~ /(^.* ..:..:..) [\w\-]+ kernel:(.*)(IN=.*)(PHYSIN=.*)$/) {}
+                       elsif ($_ =~ /(^.* ..:..:..) [\w\-]+ kernel:(.*)(IN=.*)$/) {}
+                       my $timestamp = $1; my $chain = $2; my $packet = $3;
+                       $timestamp =~ /(...) (..) (..:..:..)/;
+                       my $month = $1; my $day = $2; my $time = $3; my $iface;
+
+                       # If ipv6 uses bridge, the use PHYSIN and PHYSOUT, otherwise use IN and OUT
+                       if ($a =~ /PHYSIN\=(\w+)/)  { $iface = $1; } elsif ($a =~ /IN\=(\w+)/)  { $iface = $1; }
+                       if ($a =~ /PHYSOUT\=(\w+)/) { $out = $1;   } elsif ($a =~ /OUT\=(\w+)/) { $out = $1; }
+                       # Detect ipv4 and ipv6 addresses
+                       if (($a =~ /SRC\=(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($a =~ /SRC\=(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { $srcaddr = $1; }
+                       if (($a =~ /DST\=(([\d]{1,3})(\.([\d]{1,3})){3})/) or ($a =~ /DST\=(([0-9a-fA-F]{0,4})(\:([0-9a-fA-F]{0,4})){2,7})/)) { $dstaddr = $1; }
+                       if ($a =~ /PROTO\=(\w+)/) { $protostr = $1; }
+                       my $protostrlc = lc($protostr);
+                       if ($a =~  /SPT\=([\d\.]+)/){ $srcport = $1; }
+                       if ($a =~  /DPT\=([\d\.]+)/){ $dstport = $1; }
+
+                       if ($lines % 2) {
+                               print "<tr bgcolor='${Header::table1colour}'>\n"; 
+                       }
+                       else {
+                               print "<tr bgcolor='${Header::table2colour}'>\n"; 
+                       }
+                       print <<END
+                       <td align='center'>$time</td>
+                       <td align='center'>$chain</td>
+                       <td align='center'>$iface</td>
+                       <td align='center'>$protostr</td>
+                       <td align='center'>
+                       <table width='100%' cellpadding='0' cellspacing='0'><tr>
+                       <td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$srcaddr'>$srcaddr</a></td>
+                       </tr></table>
+                       </td>
+                               <td align='center'>$srcport</td>
+                       <td align='center'>
+                       <table width='100%' cellpadding='0' cellspacing='0'><tr>
+                       <td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$dstaddr'>$dstaddr</a></td>
+                       </tr></table>
+                       </td>
+                       <td align='center'>$dstport</td>
+                       </tr>
 END
-       ;
-       $lines++;
-    }
-  }
+                       ;
+                       $lines++;
+               }
+       }
 }
 
 print <<END
@@ -369,30 +375,34 @@ END
 
 sub oldernewer
 {
-print <<END
-<table width='100%'>
-<tr>
+       print <<END
+       <table width='100%'>
+       <tr>
 END
-;
+       ;
 
-print "<td align='center' width='50%'>";
-if ($prev != -1) {
-       print "<a href='/cgi-bin/logs.cgi/showrequestfromport.dat?$prev,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{port}'>$Lang::tr{'older'}</a>"; }
-else {
-       print "$Lang::tr{'older'}"; }
-print "</td>\n";
+       print "<td align='center' width='50%'>";
+       if ($prev != -1) {
+               print "<a href='/cgi-bin/logs.cgi/showrequestfromport.dat?$prev,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{port}'>$Lang::tr{'older'}</a>"; 
+       }
+       else {
+               print "$Lang::tr{'older'}"; 
+       }
+       print "</td>\n";
 
-print "<td align='center' width='50%'>";
-if ($next != -1) {
-       print "<a href='/cgi-bin/logs.cgi/showrequestfromport.dat?$next,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{port}'>$Lang::tr{'newer'}</a>"; }
-else {
-       print "$Lang::tr{'newer'}"; }
-print "</td>\n";
+       print "<td align='center' width='50%'>";
+       if ($next != -1) {
+               print "<a href='/cgi-bin/logs.cgi/showrequestfromport.dat?$next,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{port}'>$Lang::tr{'newer'}</a>"; 
+       }
+       else {
+               print "$Lang::tr{'newer'}"; 
+       }
+       print "</td>\n";
 
-print <<END
-</tr>
-</table>
+       print <<END
+       </tr>
+       </table>
 END
-;
+       ;
 }