]> git.ipfire.org Git - thirdparty/AWStats.git/commitdiff
Fixed pb when using several tags with different offset in LogFile name.
authoreldy <>
Sun, 8 Sep 2002 20:36:02 +0000 (20:36 +0000)
committereldy <>
Sun, 8 Sep 2002 20:36:02 +0000 (20:36 +0000)
wwwroot/cgi-bin/awstats.pl

index ac5238c434d8ec88a269b82c05f140ee22d7156c..1d6782d4993c898849ef673143794ad4d6c8807b 100644 (file)
@@ -1067,7 +1067,8 @@ sub Read_Language_Tooltip {
 sub Check_Config {
        if ($Debug) { debug("Call to Check_Config"); }
        # Main section
-       if ($LogFile =~ /%([ymdhwYMDHWNS]+)-(\d*)/) {
+       while ($LogFile =~ /%([ymdhwYMDHWNS]+)-(\d+)/) {
+               my $timetag=$1;
                my $timephase=$2;
                if ($Debug) { debug(" Found a time phase of $timephase hour in log file name",1); }
                # Get older time
@@ -1089,15 +1090,18 @@ sub Check_Config {
                if ($olderhour < 10) { $olderhour = "0$olderhour"; }
                if ($oldermin < 10) { $oldermin = "0$oldermin"; }
                if ($oldersec < 10) { $oldersec = "0$oldersec"; }
-               $LogFile =~ s/%YYYY-$timephase/$olderyear/ig;
-               $LogFile =~ s/%YY-$timephase/$oldersmallyear/ig;
-               $LogFile =~ s/%MM-$timephase/$oldermonth/ig;
-               $LogFile =~ s/%DD-$timephase/$olderday/ig;
-               $LogFile =~ s/%HH-$timephase/$olderhour/ig;
-               $LogFile =~ s/%WM-$timephase/$olderweekofmonth/ig;
-               $LogFile =~ s/%WY-$timephase/$olderweekofyear/ig;
-               $LogFile =~ s/%DW-$timephase/$olderwday/ig;
-               $LogFile =~ s/%NS-$timephase/$olderns/ig;
+               # Replace tag with new value
+               if ($timetag =~ /YYYY/i) { $LogFile =~ s/%YYYY-$timephase/$olderyear/ig; next; }
+               if ($timetag =~ /YY/i)   { $LogFile =~ s/%YY-$timephase/$oldersmallyear/ig; next;  }
+               if ($timetag =~ /MM/i)   { $LogFile =~ s/%MM-$timephase/$oldermonth/ig; next;  }
+               if ($timetag =~ /DD/i)   { $LogFile =~ s/%DD-$timephase/$olderday/ig; next;  }
+               if ($timetag =~ /HH/i)   { $LogFile =~ s/%HH-$timephase/$olderhour/ig; next;  }
+               if ($timetag =~ /WM/i)   { $LogFile =~ s/%WM-$timephase/$olderweekofmonth/ig; next;  }
+               if ($timetag =~ /WY/i)   { $LogFile =~ s/%WY-$timephase/$olderweekofyear/ig; next;  }
+               if ($timetag =~ /DW/i)   { $LogFile =~ s/%DW-$timephase/$olderwday/ig; next;  }
+               if ($timetag =~ /NS/i)   { $LogFile =~ s/%NS-$timephase/$olderns/ig; next;  }
+               # If unknown tag
+               error("Error: Unknown tag '\%$timetag' in LogFile parameter.");
        }
        # Replace %YYYY %YY %MM %DD %HH with current value. Kept for backward compatibility.
        $LogFile =~ s/%YYYY/$nowyear/ig;