From: eldy <> Date: Tue, 30 Apr 2002 22:31:27 +0000 (+0000) Subject: Added -dir option to awstats_buildstaticpages.pl X-Git-Tag: AWSTATS_4_1_BETA~105 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=560ad405e3866ccc32a60c8405abc94fc2acdc10;p=thirdparty%2FAWStats.git Added -dir option to awstats_buildstaticpages.pl --- diff --git a/tools/awstats_buildstaticpages.pl b/tools/awstats_buildstaticpages.pl index bd32e0a5..02763554 100644 --- a/tools/awstats_buildstaticpages.pl +++ b/tools/awstats_buildstaticpages.pl @@ -7,6 +7,7 @@ # Launch awstats with -staticlinks option to build all static pages. # See COPYING.TXT file about AWStats GNU General Public License. #------------------------------------------------------- +# $Revision$ - $Author$ - $Date$ use strict; no strict "refs"; #use diagnostics; #use Thread; @@ -15,7 +16,6 @@ use strict; no strict "refs"; #------------------------------------------------------- # Defines #------------------------------------------------------- -# Last change $Revision$ - $Author$ - $Date$ my $REVISION='$Revision$'; $REVISION =~ /\s(.*)\s/; $REVISION=$1; my $VERSION="1.1 (build $REVISION)"; @@ -26,8 +26,9 @@ my $PROG; my $Extension; my $Config; my $Update=0; -my $AWSTATS="awstats.pl"; - +my $Awstats="awstats.pl"; +my $OutputDir=""; +my $OutputFile; #------------------------------------------------------- @@ -71,7 +72,8 @@ sub warning { my $QueryString=""; for (0..@ARGV-1) { $QueryString .= "$ARGV[$_] "; } if ($QueryString =~ /debug=/i) { $Debug=$QueryString; $Debug =~ s/.*debug=//; $Debug =~ s/&.*//; $Debug =~ s/ .*//; } if ($QueryString =~ /config=/i) { $Config=$QueryString; $Config =~ s/.*config=//; $Config =~ s/&.*//; $Config =~ s/ .*//; } -if ($QueryString =~ /awstatsprog=/i) { $AWSTATS=$QueryString; $AWSTATS =~ s/.*awstatsprog=//; $AWSTATS =~ s/&.*//; $AWSTATS =~ s/ .*//; } +if ($QueryString =~ /awstatsprog=/i) { $Awstats=$QueryString; $Awstats =~ s/.*awstatsprog=//; $Awstats =~ s/&.*//; $Awstats =~ s/ .*//; } +if ($QueryString =~ /dir=/i) { $OutputDir=$QueryString; $OutputDir =~ s/.*dir=//; $OutputDir =~ s/&.*//; $OutputDir =~ s/ .*//; } if ($QueryString =~ /update/i) { $Update=1; } ($DIR=$0) =~ s/([^\/\\]*)$//; ($PROG=$1) =~ s/\.([^\.]*)$//; $Extension=$1; @@ -81,7 +83,12 @@ if (! $Config) { print "build all possible pages allowed by option -output.\n"; print "\n"; print "Usage:\n"; - print " $PROG.$Extension [-update] -awstatsprog=pathtoawstatspl -config=...\n"; + print " $PROG.$Extension -config=configvalue -awstatsprog=pathtoawstatspl [-dir=outputdir] [-update] \n"; + print "\n"; + print " where configvalue is value for config option of AWStats software.\n"; + print " pathtoawstatspl is name of AWStats software with path (awstats.pl).\n"; + print " outputdir is name of output directory for generated pages.\n"; + print " -update option is used to update statistics before generate pages.\n"; print "\n"; print "New versions and FAQ at http://awstats.sourceforge.net\n"; exit 0; @@ -89,30 +96,30 @@ if (! $Config) { my $retour; -my $OutputFile; # Check if AWSTATS is ok -if (! -s "$AWSTATS") { - error("Can't find AWStats program ('$AWSTATS').\nUse -awstatsprog option to solve this"); +if (! -s "$Awstats") { + error("Can't find AWStats program ('$Awstats').\nUse -awstatsprog option to solve this"); exit 1; } # Launch awstats update if ($Update) { - `"$AWSTATS" -config=$Config -update`; + `"$Awstats" -config=$Config -update`; } +# Define OutputFile name +if ($OutputDir) { if ($OutputDir !~ /[\\\/]$/) { $OutputDir.="/"; } } +$OutputFile=($OutputDir?$OutputDir:"")."awstats.$Config.html"; # Launch all awstats output -$retour=`"$AWSTATS" -config=$Config -staticlinks -output 2>&1`; -$OutputFile="awstats.$Config.html"; -#$OutputFile="awstats.html"; +$retour=`"$Awstats" -config=$Config -staticlinks -output 2>&1`; open("OUTPUT",">$OutputFile") || error("Couldn't open log file \"$OutputFile\" for writing : $!"); print OUTPUT $retour; close("OUTPUT"); my @OutputList=("allhosts","lasthosts","unknownip","urldetail","unknownos","unknownbrowser","browserdetail","allkeyphrases","errors404"); for my $output (@OutputList) { - $retour=`"$AWSTATS" -config=$Config -staticlinks -output=$output 2>&1`; + $retour=`"$Awstats" -config=$Config -staticlinks -output=$output 2>&1`; $OutputFile="awstats.$Config.$output.html"; # $OutputFile="awstats.$output.html"; open("OUTPUT",">$OutputFile") || error("Couldn't open log file \"$OutputFile\" for writing : $!");