]> git.ipfire.org Git - thirdparty/AWStats.git/commitdiff
Added -dir option to awstats_buildstaticpages.pl
authoreldy <>
Tue, 30 Apr 2002 22:31:27 +0000 (22:31 +0000)
committereldy <>
Tue, 30 Apr 2002 22:31:27 +0000 (22:31 +0000)
tools/awstats_buildstaticpages.pl

index bd32e0a542934043b7721f984636dfb19e177e0a..02763554c6aa761534da127bb25c338c5dd6cd12 100644 (file)
@@ -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 : $!");