]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - html/cgi-bin/logs.cgi/log.dat
logs.cgi: fix charon string for ipsec log.
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / logs.cgi / log.dat
index d6139580a460ba89a4ce10c0ff463cd465e89c5d..c0da266f15849efb802071d995b86fe9b435e855 100644 (file)
 use strict;
 
 # enable only the following on debugging purpose
-#use warnings;
-#use CGI::Carp 'fatalsToBrowser';
+use warnings;
+use CGI::Carp 'fatalsToBrowser';
 
 require '/var/ipfire/general-functions.pl';
 require "${General::swroot}/lang.pl";
 require "${General::swroot}/header.pl";
 
-use POSIX();
+my %color = ();
+my %mainsettings = ();
+&General::readhash("${General::swroot}/main/settings", \%mainsettings);
+&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
 
-#workaround to suppress a warning when a variable is used only once
-my @dummy = ( ${Header::table2colour} );
-undef (@dummy);
+use POSIX();
 
 my %cgiparams=();
 my %logsettings=();
@@ -48,18 +49,21 @@ $cgiparams{'ACTION'} = '';
 $cgiparams{'SECTION'} = 'ipfire';
 
 my %sections = (
-        'ipfire' => '(ipfire)',
-        'red' => '(red.*|kernel: usb.*|pppd\[.*\]|chat\[.*\]|pppoe\[.*\]|pptp\[.*\]|pppoa\[.*\]|pppoa3\[.*\]|pppoeci\[.*\]|ipppd|ipppd\[.*\]|kernel: ippp\d|kernel: isdn.*|ibod\[.*\]|kernel: eth.*|dhcpcd\[.*\]|modem_run\[.*\])',
-        'dns' => '(dnsmasq\[.*\])',
-        'dhcp' => '(dhcpd)',
-        'cron' => '(fcron\[.*\])',
-        'ntp' => '(ntpd(?:ate)?\[.*\])',
-        'ssh' => '(sshd(?:\(.*\))?\[.*\])',
-        'auth' => '(\w+\(pam_unix\)\[.*\])',
-        'kernel' => '(kernel)',
-        'ipsec' => '(ipsec_[\w_]+|pluto\[.*\])',
-        'snort' => '(snort)',
-        'openvpn' => '(openvpnserver)\[.*\]'
+        'ipfire' => '(ipfire: )',
+        'red' => '(red:|pppd\[.*\]: |chat\[.*\]|pppoe\[.*\]|pptp\[.*\]|pppoa\[.*\]|pppoa3\[.*\]|pppoeci\[.*\]|ipppd|ipppd\[.*\]|kernel: ippp\d|kernel: isdn.*|ibod\[.*\]|dhcpcd\[.*\]|modem_run\[.*\])',
+        'dns' => '(dnsmasq\[.*\]: )',
+        'dhcp' => '(dhcpd: )',
+        'clamav' => '(clamd\[.*\]: |freshclam\[.*\]: )',
+        'collectd' => '(collectd\[.*\]: )',
+        'cron' => '(fcron\[.*\]: )',
+        'ntp' => '(ntpd(?:ate)?\[.*\]: )',
+        'ssh' => '(sshd(?:\(.*\))?\[.*\]: )',
+        'auth' => '(\w+\(pam_unix\)\[.*\]: )',
+        'kernel' => '(kernel: (?!DROP_))',
+        'ipsec' => '(ipsec_[\w_]+: |pluto\[.*\]: |charon: |vpnwatch: )',
+        'openvpn' => '(openvpnserver)\[.*\]: ',
+        'pakfire' => '(pakfire:) ',
+        'wireless' => '(hostapd:|kernel: ath.*:|kernel: wifi[0-9]:) '
         );
 
 # Translations for the %sections array.
@@ -69,13 +73,16 @@ my %trsections = (
         'dns' => 'DNS',
         'dhcp' => "$Lang::tr{'dhcp server'}",
         'cron' => 'Cron',
+        'collectd' => 'Collectd',
+                               'clamav' => 'ClamAV',
         'ntp' => 'NTP',
         'ssh' => 'SSH',
         'auth' => "$Lang::tr{'loginlogout'}",
         'kernel' => "$Lang::tr{'kernel'}",
         'ipsec' => 'IPSec',
         'openvpn' => 'OpenVPN',
-        'snort' => 'Snort'
+        'pakfire' => 'Pakfire',
+        'wireless' => 'Wireless'
        );
 
 
@@ -146,7 +153,7 @@ my $date = $cgiparams{'DAY'} == 0 ? '' :  $cgiparams{'DAY'} <= 9 ? "0$cgiparams{
 
 {
     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] ) ) {
@@ -160,13 +167,13 @@ my $date = $cgiparams{'DAY'} == 0 ? '' :  $cgiparams{'DAY'} <= 9 ? "0$cgiparams{
     # 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]);
+    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 $section = $sections{$cgiparams{'SECTION'}};
@@ -178,7 +185,7 @@ my $loop = 1;
 my $filestr = 0;
 my $lastdatetime;           # for debug
 my $search_for_end = 0;
-           
+
 while ($gzindex >=0 && $loop) {
         # calculate file name
         if ($gzindex == 0) {
@@ -192,7 +199,7 @@ while ($gzindex >=0 && $loop) {
            #&General::log("reading $filestr");
            READ:while (<FILE>) {
                my $line = $_;
-               if ($line =~ /^${monthstr} ${daystr} ..:..:.. [\w\-]+ ${section}(.*)/) {
+               if ($line =~ /^${monthstr} ${daystr} ..:..:.. [\w\-]+ ${section}(.*)/) {
                    # when standart viewing, just keep in memory the correct slice
                    # it starts a '$start' and size is $viewport
                    # If export, then keep all lines...
@@ -237,11 +244,11 @@ if ($cgiparams{'ACTION'} eq $Lang::tr{'export'})
 
        foreach $_ (@log)
        {
-               /^... (..) (..:..:..) [\w\-]+ ${section}(.*)$/;
+               /^... (..) (..:..:..) [\w\-]+ ${section}(.*)$/;
                my $day =  $1;
                $day =~ tr / /0/;
                my $time = $cgiparams{'DAY'} ? "$2" : "$day/$2" ;
-               print "$time $3 $4\r\n";
+  print "$time $3 $4\r\n";
        }
        exit 0;
 }
@@ -299,7 +306,7 @@ print <<END
 END
 ;
 print "<option value='0'>$Lang::tr{'all'}</option>\n";
-for (my $day = 1; $day <= 31; $day++) 
+for (my $day = 1; $day <= 31; $day++)
 {
        print "\t<option ";
        if ($day == $cgiparams{'DAY'}) {
@@ -334,7 +341,7 @@ my $prev;
        $prev = $start - ${Header::viewsize};
        $prev = 0 if ( $prev < 0);
     }
-                                   
+
 my $next;
     if ($start == $lines - ${Header::viewsize}) {
         $next = -1;
@@ -360,7 +367,7 @@ $lines = 0;
 #print '<tt>';
 foreach $_ (@log)
 {
-       /^... (..) (..:..:..) [\w\-]+ ${section}(.*)$/;
+       /^... (..) (..:..:..) [\w\-]+ ${section}(.*)$/;
        my $day =  $1;
        $day =~ tr / /0/;
        my $time = $cgiparams{'DAY'} ? "$2" : "$day/$2" ;
@@ -379,9 +386,9 @@ foreach $_ (@log)
 
 
        if ($lines % 2) {
-               print "<tr bgcolor='${Header::table1colour}'>"; }
+               print "<tr bgcolor='$color{'color20'}'>"; }
        else {
-               print "<tr bgcolor='${Header::table2colour}'>"; }
+               print "<tr bgcolor='$color{'color22'}'>"; }
        print "<td>$time<td>$sec<td>" .&Header::cleanhtml ("$d", 'y') . "</td></tr>\n";
        $lines++;
 }