From: eldy <>
Date: Sat, 10 Apr 2010 13:27:11 +0000 (+0000)
Subject: Added precious patch from Chris Larsen
X-Git-Tag: AWSTATS_7_0_BETA2~75
X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=88974bfcfe03c74305c3090247a2214c77942c2a;p=thirdparty%2FAWStats.git
Added precious patch from Chris Larsen
---
diff --git a/wwwroot/cgi-bin/awstats.pl b/wwwroot/cgi-bin/awstats.pl
index a8c55e8f..7a5d8ff5 100644
--- a/wwwroot/cgi-bin/awstats.pl
+++ b/wwwroot/cgi-bin/awstats.pl
@@ -64,8 +64,9 @@ use vars qw/
$lowerval
$PluginMode
$MetaRobot
+ $AverageVisits $AveragePages $AverageHits $AverageBytes
$TotalUnique $TotalVisits $TotalHostsKnown $TotalHostsUnknown
- $TotalPages $TotalHits $TotalBytes
+ $TotalPages $TotalHits $TotalBytes $TotalHitsErrors
$TotalNotViewedPages $TotalNotViewedHits $TotalNotViewedBytes
$TotalEntries $TotalExits $TotalBytesPages $TotalDifferentPages
$TotalKeyphrases $TotalKeywords $TotalDifferentKeyphrases $TotalDifferentKeywords
@@ -85,8 +86,9 @@ $LastUpdate = 0;
$lowerval = 0;
$PluginMode = '';
$MetaRobot = 0;
+$AverageVisits = $AveragePages = $AverageHits = $AverageBytes = 0;
$TotalUnique = $TotalVisits = $TotalHostsKnown = $TotalHostsUnknown = 0;
-$TotalPages = $TotalHits = $TotalBytes = 0;
+$TotalPages = $TotalHits = $TotalBytes = $TotalHitsErrors = 0;
$TotalNotViewedPages = $TotalNotViewedHits = $TotalNotViewedBytes = 0;
$TotalEntries = $TotalExits = $TotalBytesPages = $TotalDifferentPages = 0;
$TotalKeyphrases = $TotalKeywords = $TotalDifferentKeyphrases = 0;
@@ -996,9 +998,6 @@ EOF
# Call to plugins' function AddHTMLStyles
foreach my $pluginname ( keys %{ $PluginsLoaded{'AddHTMLStyles'} } )
{
-
- # my $function="AddHTMLStyles_$pluginname()";
- # eval("$function");
my $function = "AddHTMLStyles_$pluginname";
&$function();
}
@@ -1019,6 +1018,13 @@ EOF
# print "\n";
+}
+
+#-------------------------------------------------------
+# PLUGIN FUNCTION: Graph_Monthly
+# Prints the image code to display a column chart of monthly usage
+# Parameters: None
+# Input: None
+# Output: HTML code to print a chart
+# Return: 0 OK, 1 Error
+#-------------------------------------------------------
+sub Graph_Monthly(){
+ my $chxt = "chxt=";
+ my $chxl = "chxl=";
+ my $chxs = "chxs=";
+ my $chco = "chco=";
+ my $chg = "chg=";
+ my $chs = "chs=";
+ my $cht = "cht=bvg";
+ my $chd = "chd=t:";
+ my $cba = "chbh=a"; # shows the whole month
+ my $graphwidth = $imagewidth;
+ my $graphheight = int ($imagewidth * $imageratio);
+
+ # round max values
+ foreach my $i(0..(scalar @$valmax)){
+ @$valmax[$i] = Round_Up(@$valmax[$i]);
+ }
+
+ # setup axis
+ $chxt .= "x,y,y,r"; # add an x for years
+
+ # get the month labels
+ $chxl .= "0:|";
+ $chxl .= Get_Labels();
+ # get the hits/pages max
+ $chxl .= "1:|0|".Get_Suffixed((@$valmax[0]/2),0)."|".Get_Suffixed(@$valmax[0],0)."|";
+ # get the visitors/pages max
+ $chxl .= "2:|0|".Get_Suffixed((@$valmax[2]/2),0)."|".Get_Suffixed(@$valmax[2],0)."|";
+ # get bytes
+ $chxl .= "3:|0|".Get_Suffixed((@$valmax[4]/2),1)."|".Get_Suffixed(@$valmax[4],1);
+ # TODO add the year at the start and end
+
+ # set the axis colors
+ $chxs .= "1,".@$valcolor[0]."|2,".@$valcolor[2]."|3,".@$valcolor[4];
+
+ # dump colors
+ foreach my $i(0..(scalar @$valcolor)){
+ $chco .= @$valcolor[$i];
+ if ($i < (scalar @$valcolor)-1){ $chco .= ",";}
+ }
+
+ # grid lines
+ $chg .= "0,50";
+
+ # size
+ $chs .= $graphwidth."x".$graphheight;
+
+ # finally get the data
+ $chd .= Get_Column_Data();
+
+ # string and dump
+ return "$cht&$chxl&$chxt&$chxs&$chco&$chg&$chs&$chd&$cba";
+}
+
+#-------------------------------------------------------
+# PLUGIN FUNCTION: Graph_Daily
+# Prints the image code to display a column chart of daily usage
+# Parameters: None
+# Input: None
+# Output: HTML code to print a chart
+# Return: 0 OK, 1 Error
+#-------------------------------------------------------
+sub Graph_Daily(){
+ my $chxt = "chxt=";
+ my $chxl = "chxl=";
+ my $chxs = "chxs=";
+ my $chco = "chco=";
+ my $chg = "chg=";
+ my $chs = "chs=";
+ my $cht = "cht=bvg";
+ my $chd = "chd=t:";
+ my $cba = "chbh=a"; # shows the whole month
+ my $graphwidth = $imagewidth;
+ my $graphheight = int ($imagewidth * $imageratio);
+
+ # round max values
+ foreach my $i(0..(scalar @$valmax)){
+ @$valmax[$i] = Round_Up(@$valmax[$i]);
+ }
+
+ # setup axis
+ $chxt .= "x,y,y,r"; # add an x for years
+
+ # setup axis labels
+ # get day labels
+ $chxl .= "0:|";
+ $chxl .= Get_Labels();
+ # get the hits/pages max
+ $chxl .= "1:|0|".Get_Suffixed((@$valmax[0]/2),0)."|".Get_Suffixed(@$valmax[0],0)."|";
+ # get the visitors/pages max
+ $chxl .= "2:|0|".Get_Suffixed((@$valmax[1]/2),0)."|".Get_Suffixed(@$valmax[1],0)."|";
+ # get bytes
+ $chxl .= "3:|0|".Get_Suffixed((@$valmax[3]/2),1)."|".Get_Suffixed(@$valmax[3],1);
+ # TODO month name
+
+ # set the axis colors
+ $chxs .= "1,".@$valcolor[0]."|2,".@$valcolor[1]."|3,".@$valcolor[3];
+
+ # dump colors
+ foreach my $i(0..(scalar @$valcolor)){
+ $chco .= @$valcolor[$i];
+ if ($i < (scalar @$valcolor)-1){ $chco .= ",";}
+ }
+
+ # grid lines
+ $chg .= "0,50";
+
+ # size
+ $chs .= $graphwidth."x".$graphheight;
+
+ # finally get the data
+ $chd .= Get_Column_Data();
+
+ # string and dump
+ return "$cht&$chxl&$chxt&$chxs&$chco&$chg&$chs&$chd&$cba";
+}
+
+#-------------------------------------------------------
+# PLUGIN FUNCTION: Graph_Weekly
+# Prints the image code to display a column chart of weekly usage
+# Parameters: None
+# Input: None
+# Output: HTML code to print a chart
+# Return: 0 OK, 1 Error
+#-------------------------------------------------------
+sub Graph_Weekly(){
+ my $chxt = "chxt=";
+ my $chxl = "chxl=";
+ my $chxs = "chxs=";
+ my $chco = "chco=";
+ my $chg = "chg=";
+ my $chs = "chs=";
+ my $cht = "cht=bvg";
+ my $chd = "chd=t:";
+ my $cba = "chbh=a"; # shows the whole month
+ my $graphwidth = int ($imagewidth * .75); # to maintain old look/ratio, reduce width of the weekly
+ my $graphheight = int ($imagewidth * $imageratio);
+
+ # round max values
+ foreach my $i(0..(scalar @$valmax)){
+ @$valmax[$i] = Round_Up(@$valmax[$i]);
}
+
+ # setup axis
+ $chxt .= "x,y,y,r"; # add an x for years
+
+ # setup axis labels
+ # get the day labels
+ $chxl .= "0:|";
+ $chxl .= Get_Labels();
+ # get the hits/pages max
+ $chxl .= "1:|0|".Get_Suffixed((@$valmax[0]/2),0)."|".Get_Suffixed(@$valmax[0],0)."|";
+ # get the visitors/pages max
+ $chxl .= "2:|0|".Get_Suffixed((@$valmax[1]/2),0)."|".Get_Suffixed(@$valmax[1],0)."|";
+ # get bytes
+ $chxl .= "3:|0|".Get_Suffixed((@$valmax[2]/2),1)."|".Get_Suffixed(@$valmax[2],1);
+
+ # set the axis colors
+ $chxs .= "1,".@$valcolor[0]."|2,".@$valcolor[1]."|3,".@$valcolor[2];
+
+ # dump colors
+ foreach my $i(0..(scalar @$valcolor)){
+ $chco .= @$valcolor[$i];
+ if ($i < (scalar @$valcolor)-1){ $chco .= ",";}
+ }
+
+ # grid lines
+ $chg .= "0,50";
+
+ # size
+ $chs .= $graphwidth."x".$graphheight;
+
+ # finally get the data
+ $chd .= Get_Column_Data();
+
+ # string and dump
+ return "$cht&$chxl&$chxt&$chxs&$chco&$chg&$chs&$chd&$cba";
+}
+
+#-------------------------------------------------------
+# PLUGIN FUNCTION: Graph_Hourly
+# Prints the image code to display a column chart of hourly usage
+# Parameters: None
+# Input: None
+# Output: HTML code to print a chart
+# Return: 0 OK, 1 Error
+#-------------------------------------------------------
+sub Graph_Hourly(){
+ my $chxt = "chxt=";
+ my $chxl = "chxl=";
+ my $chxs = "chxs=";
+ my $chco = "chco=";
+ my $chg = "chg=";
+ my $chs = "chs=";
+ my $cht = "cht=bvg";
+ my $chd = "chd=t:";
+ my $cba = "chbh=a"; # shows the whole month
+ my $graphwidth = $imagewidth;
+ my $graphheight = int ($imagewidth * $imageratio);
+
+ # round max values
+ foreach my $i(0..(scalar @$valmax - 1)){
+ @$valmax[$i] = Round_Up(@$valmax[$i]);
+ }
+
+ # setup axis
+ $chxt .= "x,y,y,r"; # add an x for years
+
+ # setup axis labels
+ $chxl .= "0:|";
+ $chxl .= Get_Labels();
+ # get the hits/pages max
+ $chxl .= "1:|0|".Get_Suffixed((@$valmax[0]/2),0)."|".Get_Suffixed(@$valmax[0],0)."|";
+ # get the visitors/pages max
+ $chxl .= "2:|0|".Get_Suffixed((@$valmax[1]/2),0)."|".Get_Suffixed(@$valmax[1],0)."|";
+ # get bytes
+ $chxl .= "3:|0|".Get_Suffixed((@$valmax[2]/2),1)."|".Get_Suffixed(@$valmax[2],1);
+ # TODO years
+
+ # set the axis colors
+ $chxs .= "1,".@$valcolor[0]."|2,".@$valcolor[1]."|3,".@$valcolor[2];
+
+ # dump colors
+ foreach my $i(0..(scalar @$valcolor)){
+ $chco .= @$valcolor[$i];
+ if ($i < (scalar @$valcolor)-1){ $chco .= ",";}
+ }
+
+ # grid lines
+ $chg .= "0,50";
+
+ # size
+ $chs .= $graphwidth."x".$graphheight;
+
+ # finally get the data
+ $chd .= Get_Column_Data();
+
+ # string and dump
+ return "$cht&$chxl&$chxt&$chxs&$chco&$chg&$chs&$chd&$cba";
+}
- print "\n";
+ print "google.load('visualization', '1', {'packages': ['geomap']});\n";
+ print "google.setOnLoadCallback(drawMap);\n";
+ print "function drawMap() {\n\tvar data = new google.visualization.DataTable();\n";
+
+ # get the total number of rows
+ print "\tdata.addRows(".scalar @$blocklabel.");\n";
+ print "\tdata.addColumn('string', 'Country');\n";
+ print "\tdata.addColumn('number', 'Hits');\n";
+
+ # loop and dump
+ my $i = 0;
+ for ($i .. (scalar @$blocklabel - 1)) {
+ print "\tdata.setValue($i, 0, \"".@$blocklabel[$i]."\");\n";
+ print "\tdata.setValue($i, 1, ".@$valdata[$i].");\n";
+ $i++;
+ # Google's Geomap only supports up to 400 entries
+ if ($i >= 400){ last; }
+ }
+
+ print "\tvar options = {};\n";
+ print "\toptions['dataMode'] = 'regions';\n";
+ print "\toptions['width'] = $graphwidth;\n";
+ print "\toptions['height'] = $graphheight;\n";
+ print "\tvar container = document.getElementById('$title');\n";
+ print "\tvar geomap = new google.visualization.GeoMap(container);\n";
+ print "\tgeomap.draw(data, options);\n";
+ print "};\n";
+ print "\n";
+
+ # print the div tag that will contain the map
+ print "