From: Laurent Destailleur Date: Fri, 30 Aug 2019 11:24:55 +0000 (+0200) Subject: NEW add %time6 tag in log format to support some IIS log format X-Git-Tag: AWSTATS_7_8~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39d18dab4816dfae04c6a7c0acecb685eadafc8d;p=thirdparty%2FAWStats.git NEW add %time6 tag in log format to support some IIS log format --- diff --git a/wwwroot/cgi-bin/awstats.model.conf b/wwwroot/cgi-bin/awstats.model.conf index 95a7fe54..71bb97d9 100644 --- a/wwwroot/cgi-bin/awstats.model.conf +++ b/wwwroot/cgi-bin/awstats.model.conf @@ -83,6 +83,7 @@ LogType=W # %time3 Date and time with format: Mon dd hh:mm:ss or Mon dd hh:mm:ss yyyy # %time4 Date and time with unix timestamp format: dddddddddd # %time5 Date and time with format iso: yyyy-mm-ddThh:mm:ss, with optional timezone specification (ignored) +# %time6 Date and time with format: dd/mm/yyyy, hh:mm:ss # %methodurl Method and URL with format: "GET /index.html HTTP/x.x" # %methodurlnoprot Method and URL with format: "GET /index.html" # %method Method with format: GET diff --git a/wwwroot/cgi-bin/awstats.pl b/wwwroot/cgi-bin/awstats.pl index 796521c6..7ec51252 100755 --- a/wwwroot/cgi-bin/awstats.pl +++ b/wwwroot/cgi-bin/awstats.pl @@ -9186,6 +9186,12 @@ sub DefinePerlParsingFormat { $PerlParsingFormat .= "([^$LogSeparatorWithoutStar]+T[^$LogSeparatorWithoutStar]+)(Z|[-+\.]\\d\\d[:\\.\\dZ]*)?"; } + elsif ( $f =~ /%time6$/ ) { # dd/mm/yyyy, hh:mm:ss - added additional type to format for IIS date -DWG 12/8/2008 + $pos_date = $i; + $i++; + push @fieldlib, 'date'; + $PerlParsingFormat .= "([^,]+,[^,]+)"; + } # Special for methodurl, methodurlprot and methodurlnoprot elsif ( $f =~ /%methodurl$/ ) { @@ -18415,6 +18421,25 @@ if ( $UpdateStats && $FrameName ne 'index' && $FrameName ne 'mainleft' ) next; } + # Reformat date for IIS date -DWG 12/8/2008 + if($field[$pos_date] =~ /,/) + { + $field[$pos_date] =~ s/,//; + my @split_date = split(' ',$field[$pos_date]); + my @dateparts2= split('/',$split_date[0]); + my @timeparts2= split(':',$split_date[1]); + #add leading zero + for($dateparts2[0],$dateparts2[1], $timeparts2[0], $timeparts2[1], $timeparts2[2]) { + if($_ =~ /^.$/) + { + $_ = '0'.$_; + } + + } + + $field[$pos_date] = "$dateparts2[2]-$dateparts2[0]-$dateparts2[1] $timeparts2[0]:$timeparts2[1]:$timeparts2[2]"; + } + $field[$pos_date] =~ tr/,-\/ \tT/::::::/s; # " \t" is used instead of "\s" not known with tr my @dateparts =