From: eldy <> Date: Wed, 23 Nov 2005 20:02:10 +0000 (+0000) Subject: Detect linux and bsd distributions and groups them by families X-Git-Tag: AWSTATS_6_5_BETA_2~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=221a84afa82d5bddf9f331f18a66288d304077b4;p=thirdparty%2FAWStats.git Detect linux and bsd distributions and groups them by families --- diff --git a/wwwroot/cgi-bin/awstats.pl b/wwwroot/cgi-bin/awstats.pl index d52786dc..23bcd2f1 100644 --- a/wwwroot/cgi-bin/awstats.pl +++ b/wwwroot/cgi-bin/awstats.pl @@ -226,7 +226,7 @@ use vars qw/ @DOWIndex = @fieldlib = @keylist = (); use vars qw/ @MiscListOrder %MiscListCalc -@OSFamily %BrowsersFamily @SessionsRange %SessionsAverage +%OSFamily %BrowsersFamily @SessionsRange %SessionsAverage %LangBrowserToLangAwstats %LangAWStatsToFlagAwstats @HostAliases @AllowAccessFromWebToFollowingAuthenticatedUsers @DefaultFile @SkipDNSLookupFor @@ -242,7 +242,7 @@ use vars qw/ /; @MiscListOrder=('AddToFavourites','JavascriptDisabled','JavaEnabled','DirectorSupport','FlashSupport','RealPlayerSupport','QuickTimeSupport','WindowsMediaPlayerSupport','PDFSupport'); %MiscListCalc=('TotalMisc'=>'','AddToFavourites'=>'u','JavascriptDisabled'=>'hm','JavaEnabled'=>'hm','DirectorSupport'=>'hm','FlashSupport'=>'hm','RealPlayerSupport'=>'hm','QuickTimeSupport'=>'hm','WindowsMediaPlayerSupport'=>'hm','PDFSupport'=>'hm'); -@OSFamily=('win','mac'); +%OSFamily=('win'=>'Windows','mac'=>'Macintosh','linux'=>'Linux','bsd'=>'BSD'); %BrowsersFamily=('msie'=>1,'firefox'=>2,'netscape'=>3); @SessionsRange=('0s-30s','30s-2mn','2mn-5mn','5mn-15mn','15mn-30mn','30mn-1h','1h+'); %SessionsAverage=('0s-30s',15,'30s-2mn',75,'2mn-5mn',210,'5mn-15mn',600,'15mn-30mn',1350,'30mn-1h',2700,'1h+',3600); @@ -8410,17 +8410,20 @@ if (scalar keys %HTMLOutput) { OSLOOP: foreach my $key (@keylist) { $total_h+=$_os_h{$key}; if ($_os_h{$key} > $max_h) { $max_h = $_os_h{$key}; } - foreach my $family (@OSFamily) { if ($key =~ /^$family/i) { $totalfamily_h{$family}+=$_os_h{$key}; $TotalFamily+=$_os_h{$key}; next OSLOOP; } } + foreach my $family (keys %OSFamily) { if ($key =~ /^$family/i) { $totalfamily_h{$family}+=$_os_h{$key}; $TotalFamily+=$_os_h{$key}; next OSLOOP; } } } # Write records grouped in a browser family - foreach my $family (@OSFamily) { + foreach my $family (keys %OSFamily) { my $p=' '; if ($total_h) { $p=int($totalfamily_h{$family}/$total_h*1000)/10; $p="$p %"; } my $familyheadershown=0; foreach my $key (reverse sort keys %_os_h) { if ($key =~ /^$family(.*)/i) { - if (! $familyheadershown) { - print "".uc($family).""; + if (! $familyheadershown) + { + my $family_name=''; + if ($OSFamily{$family}) { $family_name=$OSFamily{$family}; } + print "$family_name"; print "".int($totalfamily_h{$family})."$p "; print "\n"; $familyheadershown=1; @@ -8431,6 +8434,8 @@ if (scalar keys %HTMLOutput) { if ($total_h) { $p=int($_os_h{$key}/$total_h*1000)/10; $p="$p %"; } print ""; print ""; + + print "$OSHashLib{$key}"; my $bredde_h=0; if ($max_h > 0) { $bredde_h=int($BarWidth*($_os_h{$key}||0)/$max_h)+1; } @@ -10003,7 +10008,7 @@ if (scalar keys %HTMLOutput) { my $Totalh=0; my %new_os_h=(); OSLOOP: foreach my $key (keys %_os_h) { $Totalh+=$_os_h{$key}; - foreach my $family (@OSFamily) { if ($key =~ /^$family/i) { $new_os_h{"${family}cumul"}+=$_os_h{$key}; next OSLOOP; } } + foreach my $family (keys %OSFamily) { if ($key =~ /^$family/i) { $new_os_h{"${family}cumul"}+=$_os_h{$key}; next OSLOOP; } } $new_os_h{$key}+=$_os_h{$key}; } my $title="$Message[59] ($Message[77] $MaxNbOf{'OsShown'})   -   $Message[80]/$Message[58]   -   $Message[0]"; @@ -10022,9 +10027,7 @@ if (scalar keys %HTMLOutput) { my $keywithoutcumul=$key; $keywithoutcumul =~ s/cumul$//i; my $libos=$OSHashLib{$keywithoutcumul}||$keywithoutcumul; my $nameicon=$keywithoutcumul; $nameicon =~ s/[^\w]//g; - # TODO Use OSFamilyLib - if ($libos eq 'win') { $libos="Windows"; } - if ($libos eq 'mac') { $libos="Macintosh"; } + if ($OSFamily{$keywithoutcumul}) { $libos="".$OSFamily{$keywithoutcumul}.""; } print "$libos$new_os_h{$key}$p\n"; } $total_h += $new_os_h{$key};