From: eldy <> Date: Fri, 23 Nov 2007 19:18:02 +0000 (+0000) Subject: Fix: If condition ok for extrasection but key can't be found, we used the key "Failed... X-Git-Tag: AWSTATS_6_8_BETA~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4dae3dc5fcfd9c13977349fcecd2e372abd82109;p=thirdparty%2FAWStats.git Fix: If condition ok for extrasection but key can't be found, we used the key "Failed to extract key". New: Add condition HOSTINLOG --- diff --git a/docs/awstats_extra.html b/docs/awstats_extra.html index 47ebd944..99d5bb23 100644 --- a/docs/awstats_extra.html +++ b/docs/awstats_extra.html @@ -314,11 +314,13 @@ There is a lot of other possible use for Extra Sections ...

# ExtraSectionCodeFilterX is list of codes the record code field must match.
# Put an empty string for no test on code.
# ExtraSectionConditionX are conditions you can use to count or not the hit, -
# Use one of the field condition (URL,URLWITHQUERY,QUERY_STRING,REFERER,UA, -
# HOST,extraX) and a regex to match, after a coma. Use "||" for "OR". +
# Use one of the field condition +
# (URL,URLWITHQUERY,QUERY_STRING,REFERER,UA,HOSTINLOG,HOST,VHOST,extraX) +
# and a regex to match, after a coma. Use "||" for "OR".
# ExtraSectionFirstColumnTitleX is the first column title of the chart.
# ExtraSectionFirstColumnValuesX is a string to tell AWStats which field to -
# extract value from (URL,URLWITHQUERY,QUERY_STRING,REFERER,UA,HOST,extraX) +
# extract value from +
# (URL,URLWITHQUERY,QUERY_STRING,REFERER,UA,HOSTINLOG,HOST,VHOST,extraX)
# and how to extract the value (using regex syntax). Each different value
# found will appear in first column of report on a different row. Be sure
# that list of different possible values will not grow indefinitely. diff --git a/wwwroot/cgi-bin/awstats.model.conf b/wwwroot/cgi-bin/awstats.model.conf index 7bab888e..6a524cd1 100644 --- a/wwwroot/cgi-bin/awstats.model.conf +++ b/wwwroot/cgi-bin/awstats.model.conf @@ -177,7 +177,7 @@ HostAliases="localhost 127.0.0.1 REGEX[myserver\.com$]" # dramatically AWStats update process speed. Do not use on large web sites. # Note: Reverse DNS lookup is done on IPv4 only (Enable ipv6 plugin for IPv6). # Note: Result of DNS Lookup can be used to build the Country report. However -# it is highly recommanded to enable the plugin 'geoipfree' or 'geoip' to +# it is highly recommanded to enable the plugin 'geoip' or 'geoipfree' to # have an accurate Country report with no need of DNS Lookup. # Possible values: # 0 - No DNS Lookup @@ -1279,7 +1279,7 @@ color_x="C1B2E2" # Background color for number of exit pages (Default = "C1B2 # This plugin gives AWStats capability to make reverse DNS lookup on IPv6 # addresses. # Note: If you are interested in having country report, you should use the -# geoipfree or geoip plugin instead of enabled reverse DNS lookup. +# geoip or geoipfree plugin instead of enabled reverse DNS lookup. # #LoadPlugin="ipv6" @@ -1295,8 +1295,11 @@ color_x="C1B2E2" # Background color for number of exit pages (Default = "C1B2 # Country chart is built from an Internet IP-Country database. # This plugin is useless for intranet only log files. # Note: You must choose between using this plugin (need Perl Geo::IP module -# from Maxmind, database more up to date) or the GeoIPfree plugin (need -# Perl Geo::IPfree module, database less up to date). +# from Maxmind, database is free and up to date) or the GeoIPfree plugin +# (need Perl Geo::IPfree module, database is free but not up to date). +# There is two versions of Maxmind Country Database: +# You can get a free version or purchase a license from Maxmind to get/use a more +# accurate version including updates (http://www.maxmind.com/app/perl?rId=awstat) # This plugin reduces AWStats speed of 8% ! # #LoadPlugin="geoip GEOIP_STANDARD /pathto/GeoIP.dat" @@ -1306,8 +1309,8 @@ color_x="C1B2E2" # Background color for number of exit pages (Default = "C1B2 # Country chart is built from an Internet IP-Country database. # This plugin is useless for intranet only log files. # Note: You must choose between using this plugin (need Perl Geo::IPfree -# module, database less up to date) or the GeoIP plugin (need Perl Geo::IP -# module from Maxmind, database more up to date). +# module, database is free but not up to date) or the GeoIP plugin (need +# Perl Geo::IP module from Maxmind, database is also free and up to date). # Note: Activestate provide a corrupted version of Geo::IPfree 0.2 Perl # module, so install it from elsewhere (from www.cpan.org for example). # This plugin reduces AWStats speed of 10% ! @@ -1333,7 +1336,9 @@ color_x="C1B2E2" # Background color for number of exit pages (Default = "C1B2 # Note: This plugin need Maxmind GeoIP Perl module AND the city database. # Note: I get some problem with Maxmind Geo::IP Perl module with ActiveState # on Windows but it works great on Linux with default Perl. -# You need to purchase a license from Maxmind to get/use the City database. +# There is two versions of Maxmind City Database: +# You can get a free version or purchase a license from Maxmind to get/use a more +# accurate version including updates (http://www.maxmind.com/app/perl?rId=awstat) # This plugin reduces AWStats speed. # #LoadPlugin="geoip_city_maxmind GEOIP_STANDARD /pathto/GeoIPCity.dat" @@ -1449,12 +1454,12 @@ color_x="C1B2E2" # Background color for number of exit pages (Default = "C1B2 # Put an empty string for no test on code. # ExtraSectionConditionX are conditions you can use to count or not the hit, # Use one of the field condition -# (URL,URLWITHQUERY,QUERY_STRING,REFERER,UA,HOST,extraX) +# (URL,URLWITHQUERY,QUERY_STRING,REFERER,UA,HOSTINLOG,HOST,VHOST,extraX) # and a regex to match, after a coma. Use "||" for "OR". # ExtraSectionFirstColumnTitleX is the first column title of the chart. # ExtraSectionFirstColumnValuesX is a string to tell AWStats which field to # extract value from -# (URL,URLWITHQUERY,QUERY_STRING,REFERER,UA,HOST,VHOST,extraX) +# (URL,URLWITHQUERY,QUERY_STRING,REFERER,UA,HOSTINLOG,HOST,VHOST,extraX) # and how to extract the value (using regex syntax). Each different value # found will appear in first column of report on a different row. Be sure # that list of different possible values will not grow indefinitely. diff --git a/wwwroot/cgi-bin/awstats.pl b/wwwroot/cgi-bin/awstats.pl index 9b283314..dd0c7f2c 100644 --- a/wwwroot/cgi-bin/awstats.pl +++ b/wwwroot/cgi-bin/awstats.pl @@ -3494,7 +3494,7 @@ sub Save_History { $lastlinechecksum=$LastLineChecksum; } - if ($Debug) { debug(" Save_History [sectiontosave=$sectiontosave,year=$year,month=$month,lastlinenb=$lastlinenb,lastlineoffset=$lastlineoffset,lastlinechecksum=$lastlinechecksum]",1); } + if ($Debug) { debug(" Save_History [sectiontosave=$sectiontosave,year=$year,month=$month,breakdate=$breakdate,lastlinenb=$lastlinenb,lastlineoffset=$lastlineoffset,lastlinechecksum=$lastlinechecksum]",1); } my $spacebar=" "; my %keysinkeylist=(); @@ -6861,7 +6861,7 @@ if ($UpdateStats && $FrameName ne 'index' && $FrameName ne 'mainleft') { # Updat # Do DNS lookup #-------------- my $Host=$field[$pos_host]; - my $HostResolved=''; + my $HostResolved=''; # HostResolved will be defined in next paragraf if countedtraffic is true if (! $countedtraffic) { my $ip=0; @@ -7373,6 +7373,7 @@ if ($UpdateStats && $FrameName ne 'index' && $FrameName ne 'mainleft') { # Updat $_cluster_k{$field[$pos_cluster]}+=int($field[$pos_size]); #Count accesses for page (kb) } + # Analyze: Extra #--------------- foreach my $extranum (1..@ExtraName-1) { @@ -7415,9 +7416,14 @@ if ($UpdateStats && $FrameName ne 'index' && $FrameName ne 'mainleft') { # Updat if ($Debug) { debug(" Check condition '$conditiontype' must contain '$conditiontypeval' in '$field[$pos_agent]'",5); } if ($field[$pos_agent] =~ /$conditiontypeval/) { $conditionok=1; last; } } - elsif ($conditiontype eq 'HOST') { + elsif ($conditiontype eq 'HOSTINLOG') { if ($Debug) { debug(" Check condition '$conditiontype' must contain '$conditiontypeval' in '$field[$pos_host]'",5); } - if ($HostResolved =~ /$conditiontypeval/) { $conditionok=1; last; } + if ($field[$pos_host] =~ /$conditiontypeval/) { $conditionok=1; last; } + } + elsif ($conditiontype eq 'HOST') { + my $hosttouse=($HostResolved?$HostResolved:$Host); + if ($Debug) { debug(" Check condition '$conditiontype' must contain '$conditiontypeval' in '$hosttouse'",5); } + if ($hosttouse =~ /$conditiontypeval/) { $conditionok=1; last; } } elsif ($conditiontype eq 'VHOST') { if ($Debug) { debug(" Check condision '$conditiontype' must contain '$conditiontypeval' in '$field[$pos_vh]'",5); } @@ -7454,8 +7460,12 @@ if ($UpdateStats && $FrameName ne 'index' && $FrameName ne 'mainleft') { # Updat elsif ($rowkeytype eq 'UA') { if ($field[$pos_agent] =~ /$rowkeytypeval/) { $rowkeyval = "$1"; $rowkeyok = 1; last; } } + elsif ($rowkeytype eq 'HOSTINLOG') { + if ($field[$pos_host] =~ /$rowkeytypeval/) { $rowkeyval = "$1"; $rowkeyok = 1; last; } + } elsif ($rowkeytype eq 'HOST') { - if ($HostResolved =~ /$rowkeytypeval/) { $rowkeyval = "$1"; $rowkeyok = 1; last; } + my $hosttouse=($HostResolved?$HostResolved:$Host); + if ($hosttouse =~ /$rowkeytypeval/) { $rowkeyval = "$1"; $rowkeyok = 1; last; } } elsif ($rowkeytype eq 'VHOST') { if ($field[$pos_vh] =~ /$rowkeytypeval/) { $rowkeyval = "$1"; $rowkeyok = 1; last; } @@ -7465,8 +7475,9 @@ if ($UpdateStats && $FrameName ne 'index' && $FrameName ne 'mainleft') { # Updat } else { error("Wrong value of parameter ExtraSectionFirstColumnValues$extranum"); } } - if (! $rowkeyok) { next; } # End for this section - if ($Debug) { debug(" Key val was found: $rowkeyval",5); } + if (! $rowkeyok) { next; } # End for this section + if (! $rowkeyval) { $rowkeyval='Failed to extract key'; } + if ($Debug) { debug(" Key val found: $rowkeyval",5); } # Apply function on $rowkeyval if ($ExtraFirstColumnFunction[$extranum])