]> git.ipfire.org Git - thirdparty/AWStats.git/commitdiff
Removed Perl warning.
authoreldy <>
Wed, 23 Oct 2002 17:16:58 +0000 (17:16 +0000)
committereldy <>
Wed, 23 Oct 2002 17:16:58 +0000 (17:16 +0000)
tools/configure.pl
tools/logresolvemerge.pl
wwwroot/cgi-bin/awstats.pl
wwwroot/cgi-bin/plugins/graph3d.pm

index 0761de5b9c331daeb97bb9aec734dedaa9f4644c..39bf54004fdc3420d6d3dc36804e016852977c1a 100644 (file)
@@ -10,8 +10,9 @@
 #-------------------------------------------------------
 # Defines
 #-------------------------------------------------------
-my $REVISION='$Revision$'; $REVISION =~ /\s(.*)\s/; $REVISION=$1;
-my $VERSION="1.0 (build $REVISION)";
+use vars qw/ $REVISION $VERSION /;
+$REVISION='$Revision$'; $REVISION =~ /\s(.*)\s/; $REVISION=$1;
+$VERSION="1.0 (build $REVISION)";
 
 # Default value of DIRCONFIG and AWSTATSSCRIPT
 my $DIRCONFIG = "/etc/opt/awstats";
@@ -45,8 +46,6 @@ sub debug {
 #-------------------------------------------------------
 my $QueryString=""; for (0..@ARGV-1) { $QueryString .= "$ARGV[$_] "; }
 if ($QueryString =~ /debug=/i) { $Debug=$QueryString; $Debug =~ s/.*debug=//; $Debug =~ s/&.*//; $Debug =~ s/ .*//; }
-if ($QueryString =~ /dnslookup/i) { $DNSLookup=1; }
-if ($QueryString =~ /showsteps/i) { $ShowSteps=1; }
 
 my $helpfound=0;
 for (0..@ARGV-1) {
@@ -80,6 +79,7 @@ if ($nowsec < 10) { $nowsec = "0$nowsec"; }
 
 
 print "This script is not ready yet.\n";
+print "See AWStats setup documentation instead (file docs/index.html).\n";
 
 
 
index b52cd5ec2059f99ac14008b448bbb11d69935212..148ebd734401ad91996075143d82fb587c45db74 100644 (file)
@@ -20,8 +20,9 @@ use strict; no strict "refs";
 #-------------------------------------------------------
 # Defines
 #-------------------------------------------------------
-my $REVISION='$Revision$'; $REVISION =~ /\s(.*)\s/; $REVISION=$1;
-my $VERSION="1.2 (build $REVISION)";
+use vars qw/ $REVISION $VERSION /;
+$REVISION='$Revision$'; $REVISION =~ /\s(.*)\s/; $REVISION=$1;
+$VERSION="1.2 (build $REVISION)";
 
 # ---------- Init variables --------
 my $Debug=0;
@@ -35,8 +36,6 @@ my $DirData="";
 my $DNSLookupAlreadyDone=0;
 my $QueuePoolSize=10;
 my $NbOfLinesForBenchmark=5000;
-my $nowtime = my $nowweekofmonth = my $nowdaymod = my $nowsmallyear = 0; 
-my $nowsec = my $nowmin = my $nowhour = my $nowday = my $nowmonth = my $nowyear = my $nowwday = 0;
 # ---------- Init arrays --------
 my @SkipDNSLookupFor=();
 # ---------- Init hash arrays --------
index 2462d5b49e7e8f35dbf64eea167c587ea1efbbcc..7d6d394316ea124f965eb288136d931a050c29e8 100644 (file)
@@ -19,8 +19,8 @@ use Socket;
 # Defines
 #-----------------------------------------------------------------------------
 use vars qw/ $REVISION $VERSION /;
-my $REVISION='$Revision$'; $REVISION =~ /\s(.*)\s/; $REVISION=$1;
-my $VERSION="5.1 (build $REVISION)";
+$REVISION='$Revision$'; $REVISION =~ /\s(.*)\s/; $REVISION=$1;
+$VERSION="5.1 (build $REVISION)";
 
 # ---------- Init variables -------
 # Constants
@@ -1660,13 +1660,17 @@ sub Read_Plugins {
                                        my $pluginpath="${searchdir}${pluginfile}.pm";
                                        if (-s "$pluginpath") {
                                                if ($Debug) { debug(" Try to init plugin '$pluginname' ($pluginpath) with param '$pluginparam'",1); }
-                                               require "$pluginpath";
+                                               my $initreq=require "$pluginpath";
+                                               if (! $initreq || $initreq =~ /^error/i) {
+                                                       # Load failed, we stop here
+                                                       &error("Plugin load for plugin '$pluginname' failed with return code: $initreq");
+                                               }
                                                my $ret;        # To get init return
                                                my $initfunction="\$ret=Init_$pluginname('$pluginparam')";
                                                my $initret=eval("$initfunction");
                                                if (! $initret || $initret =~ /^error/i) {
-                                                       # Init failed, we stop here
-                                                       &error("Plugin init for plugin '$pluginname' fails with return code: $initret");
+                                                       # Init function failed, we stop here
+                                                       &error("Plugin init for plugin '$pluginname' failed with return code: $initret");
                                                }
                                                # Plugin load and init successfull
                                                foreach my $elem (split(/\s+/,$initret)) {
@@ -4878,6 +4882,9 @@ if ($UpdateStats && $FrameName ne "index" && $FrameName ne "mainleft") {  # Updat
                        $lastprocessedyearmonth=sprintf("%04i%02i",$lastprocessedyear,$lastprocessedmonth);
                }
 
+               # Convert $field[$pos_size]
+               # if ($field[$pos_size] eq '-') { $field[$pos_size]=0; }
+               
                # Check return status code
                #-------------------------
                if ($protocol == 1 || $protocol == 4) {         # HTTP record or Stream record
@@ -4887,7 +4894,7 @@ if ($UpdateStats && $FrameName ne "index" && $FrameName ne "mainleft") {  # Updat
                        else {                                                                          # Code is not valid
                                if ($field[$pos_code] =~ /^\d\d\d$/) {                                  # Keep error code and next
                                        $_errors_h{$field[$pos_code]}++;
-                                       $_errors_k{$field[$pos_code]}+=$field[$pos_size];
+                                       $_errors_k{$field[$pos_code]}+=int($field[$pos_size]);
                                        foreach my $code (keys %TrapInfosForHTTPErrorCodes) {
                                                if ($field[$pos_code] == $code) { $_sider404_h{$field[$pos_url]}++; $_referer404_h{$field[$pos_url]}=$field[$pos_referer]; }
                                        }
@@ -4904,7 +4911,7 @@ if ($UpdateStats && $FrameName ne "index" && $FrameName ne "mainleft") {  # Updat
                        if ($field[$pos_code] != 1) {                           # Code is not valid
                                $field[$pos_size]=0;
                                $_errors_h{$field[$pos_code]}++;
-                               $_errors_k{$field[$pos_code]}+=$field[$pos_size];
+                               $_errors_k{$field[$pos_code]}+=int($field[$pos_size]);
                                next;
                        }
                }
@@ -4936,7 +4943,7 @@ if ($UpdateStats && $FrameName ne "index" && $FrameName ne "mainleft") {  # Updat
                                if ($uarobot ne "-") {
                                        if ($Debug) { debug("UserAgent '$UserAgent' contains robot ID '$uarobot'",2); }
                                        $_robot_h{$uarobot}++;
-                                       $_robot_k{$uarobot}+=$field[$pos_size];
+                                       $_robot_k{$uarobot}+=int($field[$pos_size]);
                                        $_robot_l{$uarobot}=$timerecord;
                                        next;
                                }
@@ -4975,7 +4982,7 @@ if ($UpdateStats && $FrameName ne "index" && $FrameName ne "mainleft") {  # Updat
                        if ($URLNotCaseSensitive) { $field[$pos_url] =~ tr/A-Z/a-z/; }
                        $field[$pos_url] =~ s/\?(.*)$//;
                        $urlwithnoquery=$field[$pos_url];
-                       $standalonequery="$1";
+                       $standalonequery=$1||"";
                }
                # Here now urlwithnoquery is /mydir/mypage.ext, /mydir, /
 
@@ -5003,7 +5010,7 @@ if ($UpdateStats && $FrameName ne "index" && $FrameName ne "mainleft") {  # Updat
                        }
                }
                elsif ($pos_gzipratio>=0 && ($field[$pos_gzipratio] =~ /(\d*)pct./)) {
-                       $_filetypes_gz_in{$extension}+=$field[$pos_size];
+                       $_filetypes_gz_in{$extension}+=int($field[$pos_size]);
                        $_filetypes_gz_out{$extension}+=int($field[$pos_size]*(1-$1/100));      # out size calculated from pct.
                }
 
@@ -5022,10 +5029,10 @@ if ($UpdateStats && $FrameName ne "index" && $FrameName ne "mainleft") {        # Updat
                        $MonthPages{$lastprocessedyearmonth}++;
                        $_time_p[$hourrecord]++;                                                                                        #Count accesses for hour (page)
                        $_url_p{$field[$pos_url]}++;                                                                            #Count accesses for page (page)
-                       $_url_k{$field[$pos_url]}+=$field[$pos_size];
+                       $_url_k{$field[$pos_url]}+=int($field[$pos_size]);
                }
                $_time_h[$hourrecord]++; $MonthHits{$lastprocessedyearmonth}++; $DayHits{$yearmonthdayrecord}++;        #Count accesses for hour (hit)
-               $_time_k[$hourrecord]+=$field[$pos_size]; $MonthBytes{$lastprocessedyearmonth}+=$field[$pos_size]; $DayBytes{$yearmonthdayrecord}+=$field[$pos_size];   #Count accesses for hour (kb)
+               $_time_k[$hourrecord]+=int($field[$pos_size]); $MonthBytes{$lastprocessedyearmonth}+=int($field[$pos_size]); $DayBytes{$yearmonthdayrecord}+=int($field[$pos_size]);    #Count accesses for hour (kb)
 
                # Analyze: Login
                #---------------
@@ -5037,7 +5044,7 @@ if ($UpdateStats && $FrameName ne "index" && $FrameName ne "mainleft") {  # Updat
                                $_login_p{$field[$pos_logname]}++;                                                              #Count accesses for page (page)
                        }
                        $_login_h{$field[$pos_logname]}++;                                                                      #Count accesses for page (hit)
-                       $_login_k{$field[$pos_logname]}+=$field[$pos_size];                                     #Count accesses for page (kb)
+                       $_login_k{$field[$pos_logname]}+=int($field[$pos_size]);                        #Count accesses for page (kb)
                        $_login_l{$field[$pos_logname]}=$timerecord;
                }
 
@@ -5101,7 +5108,7 @@ if ($UpdateStats && $FrameName ne "index" && $FrameName ne "mainleft") {  # Updat
                }
                if ($PageBool) { $_domener_p{$Domain}++; }
                $_domener_h{$Domain}++;
-               $_domener_k{$Domain}+=$field[$pos_size];
+               $_domener_k{$Domain}+=int($field[$pos_size]);
 
                # Analyze: Host, URL and Session
                #-------------------------------
@@ -5180,7 +5187,7 @@ if ($UpdateStats && $FrameName ne "index" && $FrameName ne "mainleft") {  # Updat
                        $_host_p{$_}++;
                }
                $_host_h{$_}++;
-               $_host_k{$_}+=$field[$pos_size];
+               $_host_k{$_}+=int($field[$pos_size]);
 
                # Analyze: Browser and OS
                #------------------------
@@ -5421,13 +5428,13 @@ if ($UpdateStats && $FrameName ne "index" && $FrameName ne "mainleft") {        # Updat
                if ($pos_emails>=0 && $field[$pos_emails]) {
                        if ($field[$pos_emails] !~ /\@/) { $field[$pos_emails].="\@$SiteDomain"; }
                        $_emails_h{lc($field[$pos_emails])}++;                                                                  #Count accesses for sender email (hit)
-                       $_emails_k{lc($field[$pos_emails])}+=$field[$pos_size];                                 #Count accesses for sender email (kb)
+                       $_emails_k{lc($field[$pos_emails])}+=int($field[$pos_size]);                                    #Count accesses for sender email (kb)
                        $_emails_l{lc($field[$pos_emails])}=$timerecord;
                }
                if ($pos_emailr>=0 && $field[$pos_emailr]) {
                        if ($field[$pos_emailr] !~ /\@/) { $field[$pos_emailr].="\@$SiteDomain"; }
                        $_emailr_h{lc($field[$pos_emailr])}++;                                                                  #Count accesses for receiver email (hit)
-                       $_emailr_k{lc($field[$pos_emailr])}+=$field[$pos_size];                                 #Count accesses for receiver email (kb)
+                       $_emailr_k{lc($field[$pos_emailr])}+=int($field[$pos_size]);                                    #Count accesses for receiver email (kb)
                        $_emailr_l{lc($field[$pos_emailr])}=$timerecord;
                }
 
@@ -5521,7 +5528,7 @@ if ($UpdateStats && $FrameName ne "index" && $FrameName ne "mainleft") {  # Updat
                        # Needs to be tested because this is most likely a huge resource hog (cpu).
                        if ($ExtraSectionStatTypes[$extranum] =~ m/P/i && $PageBool) { ${'_section_' . $extranum . '_p'}{$col_value}++; }
                        if ($ExtraSectionStatTypes[$extranum] =~ m/H/i) { ${'_section_' . $extranum . '_h'}{$col_value}++; }
-                       if ($ExtraSectionStatTypes[$extranum] =~ m/B/i) { ${'_section_' . $extranum . '_k'}{$col_value}+=$field[$pos_size]; }
+                       if ($ExtraSectionStatTypes[$extranum] =~ m/B/i) { ${'_section_' . $extranum . '_k'}{$col_value}+=int($field[$pos_size]); }
                        if ($ExtraSectionStatTypes[$extranum] =~ m/L/i) {
                                if (${'_section_' . $extranum . '_l'}{$col_value} < $timerecord) { ${'_section_' . $extranum . '_l'}{$col_value}=$timerecord; }
                        }
index 09fc02233e063713b19ec384be8c0e414ed888bd..ce878d6cd76a9f039354ffa339d30f52410f0535 100644 (file)
@@ -3,14 +3,14 @@
 # Graph3d AWStats plugin
 # Allow AWStats to use 3D graphs in its report
 #-----------------------------------------------------------------------------
-# Perl Required Modules: Graph3D
+# Perl Required Modules: GD::Graph
 #-----------------------------------------------------------------------------
 # $Revision$ - $Author$ - $Date$
 
 
 # <-----
 # ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES
-use GD::Graph3d;
+if (!eval ('require "GD/Graph/bars3d.pm";')) { return "Error: Need Perl module GD::Graph"; }
 # ----->
 use strict;no strict "refs";
 
@@ -20,7 +20,7 @@ use strict;no strict "refs";
 # PLUGIN VARIABLES
 #-----------------------------------------------------------------------------
 my $PluginNeedAWStatsVersion="5.1";
-my $PluginHooksFunctions="";
+my $PluginHooksFunctions="ShowMonthGraph";
 
 
 
@@ -29,15 +29,70 @@ my $PluginHooksFunctions="";
 #-----------------------------------------------------------------------------
 sub Init_graph3d {
        my $InitParams=shift;
-
-       # <-----
-       # YOU CAN ENTER HERE CODE TO INIT PLUGIN GLOBAL VARIABLES
-       $PluginHashfilesUpToDate=1;
-       # ----->
-
        my $checkversion=&Check_Plugin_Version($PluginNeedAWStatsVersion);
        return ($checkversion?$checkversion:"$PluginHooksFunctions");
 }
 
 
+#-------------------------------------------------------
+# Genere un fichier image .png du graphique du tableau de bord
+# Parameters:  $max_value, @data
+# Input:        None
+# Output:       Png file
+# Return:              0 OK, 1 Error
+#-------------------------------------------------------
+sub ShowMonthGraph() {
+       my $max_value=shift;
+       my $graphwidth=780;
+       my $graphheight=400;
+       my @data=shift;
+       if (! @data) { 
+               # Si tableau de donnĂ©es vide
+               return 1;
+       }
+       
+       $max_value = (int($max_value/100)+1)*100;
+               
+       # Make a new graph object that is 900 pixels wide by 500 pixels high
+       my $graph = new GD::Graph::bars3d($graphwidth, $graphheight);
+       
+       # Set some labels
+       $graph->set( 
+               x_label           => 'xxx',
+               y_label           => 'yyy',
+               title             => '',
+               overwrite                 => 1,
+               long_ticks                => 0,
+               legend_placement  => 'RC',
+               legend_spacing    => 10,
+               x_ticks                   => 1,
+               dclrs                     => ['#0000FF', '#9900FF', '#CC00FF', '#FF0099'],
+               bar_spacing               => 1,
+               title                     => 'aaaaaaaa',
+               y_max_value               => $max_value
+       );
+       
+       $graph->set_legend('xxx', 'yyy', 'zzz', 'www');
+       $graph->set_legend_font(GD::Font->MediumBold);
+       $graph->set_x_label_font(GD::Font->MediumBold);
+       $graph->set_y_label_font(GD::Font->MediumBold);
+       $graph->set_title_font(GD::Font->Giant);
+       
+       # Plot the graph to a GD object
+       my $gd = $graph->plot( \@data );
+
+       # Figure out what the default output format is
+       my $format = $graph->export_format;
+
+
+       # Now write image to output
+       print IMG $gd->png();
+
+       return 0;
+}
+
+
+
+
+
 1;     # Do not remove this line