Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 297
- Log:
Updated to AWStats 7.0.
- Author:
- rool
- Date:
- Fri Mar 18 13:33:29 +0000 2011
- Size:
- 19594 Bytes
- Properties:
- Property svn:executable is set
1 | #!/usr/bin/perl |
2 | #------------------------------------------------------------------------------ |
3 | # Launch awstats with -staticlinks option to build all static pages. |
4 | # See COPYING.TXT file about AWStats GNU General Public License. |
5 | #------------------------------------------------------------------------------ |
6 | # $Revision: 1.40 $ - $Author: eldy $ - $Date: 2010/08/04 12:56:50 $ |
7 | |
8 | #$|=1; |
9 | #use warnings; # Must be used in test mode only. This reduce a little process speed |
10 | #use diagnostics; # Must be used in test mode only. This reduce a lot of process speed |
11 | use strict;no strict "refs"; |
12 | use Time::Local; # use Time::Local 'timelocal_nocheck' is faster but not supported by all Time::Local modules |
13 | |
14 | |
15 | #------------------------------------------------------------------------------ |
16 | # Defines |
17 | #------------------------------------------------------------------------------ |
18 | my $REVISION='$Revision: 1.40 $'; $REVISION =~ /\s(.*)\s/; $REVISION=$1; |
19 | my $VERSION="1.2 (build $REVISION)"; |
20 | |
21 | # ---------- Init variables -------- |
22 | my $Debug=0; |
23 | my $DIR; |
24 | my $PROG; |
25 | my $Extension; |
26 | my $SiteConfig; |
27 | my $Update=0; |
28 | my $BuildPDF=0; |
29 | my $BuildDate=0; |
30 | my $Lang; |
31 | my $YearRequired; |
32 | my $MonthRequired; |
33 | my $DayRequired; |
34 | my $Awstats='awstats.pl'; |
35 | my $AwstatsDir=''; |
36 | my $HtmlDoc='htmldoc'; # ghtmldoc.exe |
37 | my $StaticExt='html'; |
38 | my $DirIcons=''; |
39 | my $DirConfig=''; |
40 | my $OutputDir=''; |
41 | my $OutputSuffix; |
42 | my $OutputFile; |
43 | my @pages=(); |
44 | my @OutputList=(); |
45 | my $FileConfig; |
46 | my $FileSuffix; |
47 | my $DatabaseBreak; |
48 | use vars qw/ |
49 | $ShowAuthenticatedUsers $ShowFileSizesStats $ShowScreenSizeStats $ShowSMTPErrorsStats |
50 | $ShowEMailSenders $ShowEMailReceivers $ShowWormsStats $ShowClusterStats |
51 | $ShowMenu $ShowMonthStats $ShowDaysOfMonthStats $ShowDaysOfWeekStats |
52 | $ShowHoursStats $ShowDomainsStats $ShowHostsStats |
53 | $ShowRobotsStats $ShowSessionsStats $ShowPagesStats $ShowFileTypesStats |
54 | $ShowOSStats $ShowBrowsersStats $ShowOriginStats |
55 | $ShowKeyphrasesStats $ShowKeywordsStats $ShowMiscStats $ShowHTTPErrorsStats |
56 | $BuildReportFormat |
57 | @ExtraName |
58 | @PluginsToLoad |
59 | /; |
60 | @ExtraName = (); |
61 | @PluginsToLoad = (); |
62 | # ----- Time vars ----- |
63 | use vars qw/ |
64 | $starttime |
65 | $nowtime $tomorrowtime |
66 | $nowweekofmonth $nowweekofyear $nowdaymod $nowsmallyear |
67 | $nowsec $nowmin $nowhour $nowday $nowmonth $nowyear $nowwday $nowyday $nowns |
68 | /; |
69 | |
70 | |
71 | #------------------------------------------------------------------------------ |
72 | # Functions |
73 | #------------------------------------------------------------------------------ |
74 | |
75 | #------------------------------------------------------------------------------ |
76 | # Function: Write error message and exit |
77 | # Parameters: $message |
78 | # Input: None |
79 | # Output: None |
80 | # Return: None |
81 | #------------------------------------------------------------------------------ |
82 | sub error { |
83 | print "Error: $_[0].\n"; |
84 | exit 1; |
85 | } |
86 | |
87 | #------------------------------------------------------------------------------ |
88 | # Function: Write a warning message |
89 | # Parameters: $message |
90 | # Input: $WarningMessage %HTMLOutput |
91 | # Output: None |
92 | # Return: None |
93 | #------------------------------------------------------------------------------ |
94 | sub warning { |
95 | my $messagestring=shift; |
96 | debug("$messagestring",1); |
97 | # if ($WarningMessages) { |
98 | # if ($HTMLOutput) { |
99 | # $messagestring =~ s/\n/\<br \/\>/g; |
100 | # print "$messagestring<br />\n"; |
101 | # } |
102 | # else { |
103 | print "$messagestring\n"; |
104 | # } |
105 | # } |
106 | } |
107 | |
108 | #------------------------------------------------------------------------------ |
109 | # Function: Write debug message and exit |
110 | # Parameters: $string $level |
111 | # Input: %HTMLOutput $Debug=required level $DEBUGFORCED=required level forced |
112 | # Output: None |
113 | # Return: None |
114 | #------------------------------------------------------------------------------ |
115 | sub debug { |
116 | my $level = $_[1] || 1; |
117 | if ($Debug >= $level) { |
118 | my $debugstring = $_[0]; |
119 | if ($ENV{"GATEWAY_INTERFACE"}) { $debugstring =~ s/^ /   /; $debugstring .= "<br />"; } |
120 | print localtime(time)." - DEBUG $level - $debugstring\n"; |
121 | } |
122 | } |
123 | |
124 | #------------------------------------------------------------------------------ |
125 | # Function: Read config file |
126 | # Parameters: None or configdir to scan |
127 | # Input: $DIR $PROG $SiteConfig |
128 | # Output: Global variables |
129 | # Return: - |
130 | #------------------------------------------------------------------------------ |
131 | sub Read_Config { |
132 | # Check config file in common possible directories : |
133 | # Windows : "$DIR" (same dir than awstats.pl) |
134 | # Standard, Mandrake and Debian package : "/etc/awstats" |
135 | # Other possible directories : "/usr/local/etc/awstats", "/etc" |
136 | # FHS standard, Suse package : "/etc/opt/awstats" |
137 | my $configdir=shift; |
138 | my @PossibleConfigDir=(); |
139 | |
140 | if ($configdir) { @PossibleConfigDir=("$configdir"); } |
141 | else { @PossibleConfigDir=("$AwstatsDir","$DIR","/etc/awstats","/usr/local/etc/awstats","/etc","/etc/opt/awstats"); } |
142 | |
143 | # Open config file |
144 | $FileConfig=$FileSuffix=''; |
145 | foreach my $dir (@PossibleConfigDir) { |
146 | my $searchdir=$dir; |
147 | if ($searchdir && $searchdir !~ /[\\\/]$/) { $searchdir .= "/"; } |
148 | if (open(CONFIG,"${searchdir}awstats.$SiteConfig.conf")) { $FileConfig="${searchdir}awstats.$SiteConfig.conf"; $FileSuffix=".$SiteConfig"; last; } |
149 | if (open(CONFIG,"${searchdir}awstats.conf")) { $FileConfig="${searchdir}awstats.conf"; $FileSuffix=''; last; } |
150 | } |
151 | if (! $FileConfig) { error("Couldn't open config file \"awstats.$SiteConfig.conf\" nor \"awstats.conf\" after searching in path \"".join(',',@PossibleConfigDir)."\": $!"); } |
152 | |
153 | # Analyze config file content and close it |
154 | &Parse_Config( *CONFIG , 1 , $FileConfig); |
155 | close CONFIG; |
156 | } |
157 | |
158 | #------------------------------------------------------------------------------ |
159 | # Function: Parse content of a config file |
160 | # Parameters: opened file handle, depth level, file name |
161 | # Input: - |
162 | # Output: Global variables |
163 | # Return: - |
164 | #------------------------------------------------------------------------------ |
165 | sub Parse_Config { |
166 | my ( $confighandle ) = $_[0]; |
167 | my $level = $_[1]; |
168 | my $configFile = $_[2]; |
169 | my $versionnum=0; |
170 | my $conflinenb=0; |
171 | |
172 | if ($level > 10) { error("$PROG can't read down more than 10 level of includes. Check that no 'included' config files include their parent config file (this cause infinite loop)."); } |
173 | |
174 | while (<$confighandle>) { |
175 | chomp $_; s/\r//; |
176 | $conflinenb++; |
177 | |
178 | # Extract version from first line |
179 | if (! $versionnum && $_ =~ /^# AWSTATS CONFIGURE FILE (\d+).(\d+)/i) { |
180 | $versionnum=($1*1000)+$2; |
181 | #if ($Debug) { debug(" Configure file version is $versionnum",1); } |
182 | next; |
183 | } |
184 | |
185 | if ($_ =~ /^\s*$/) { next; } |
186 | |
187 | # Check includes |
188 | if ($_ =~ /^Include "([^\"]+)"/ || $_ =~ /^#include "([^\"]+)"/) { # #include kept for backward compatibility |
189 | my $includeFile = $1; |
190 | if ($Debug) { debug("Found an include : $includeFile",2); } |
191 | if ( $includeFile !~ /^[\\\/]/ ) { |
192 | # Correct relative include files |
193 | if ($FileConfig =~ /^(.*[\\\/])[^\\\/]*$/) { $includeFile = "$1$includeFile"; } |
194 | } |
195 | if ($level > 1) { |
196 | warning("Warning: Perl versions before 5.6 cannot handle nested includes"); |
197 | next; |
198 | } |
199 | local( *CONFIG_INCLUDE ); # To avoid having parent file closed when include file is closed |
200 | if ( open( CONFIG_INCLUDE, $includeFile ) ) { |
201 | &Parse_Config( *CONFIG_INCLUDE , $level+1, $includeFile); |
202 | close( CONFIG_INCLUDE ); |
203 | } |
204 | else { |
205 | error("Could not open include file: $includeFile" ); |
206 | } |
207 | next; |
208 | } |
209 | |
210 | # Remove comments |
211 | if ($_ =~ /^\s*#/) { next; } |
212 | $_ =~ s/\s#.*$//; |
213 | |
214 | # Extract param and value |
215 | my ($param,$value)=split(/=/,$_,2); |
216 | $param =~ s/^\s+//; $param =~ s/\s+$//; |
217 | |
218 | # If not a param=value, try with next line |
219 | if (! $param) { warning("Warning: Syntax error line $conflinenb in file '$configFile'. Config line is ignored."); next; } |
220 | if (! defined $value) { warning("Warning: Syntax error line $conflinenb in file '$configFile'. Config line is ignored."); next; } |
221 | |
222 | if ($value) { |
223 | $value =~ s/^\s+//; $value =~ s/\s+$//; |
224 | $value =~ s/^\"//; $value =~ s/\";?$//; |
225 | # Replace __MONENV__ with value of environnement variable MONENV |
226 | # Must be able to replace __VAR_1____VAR_2__ |
227 | while ($value =~ /__([^\s_]+(?:_[^\s_]+)*)__/) { my $var=$1; $value =~ s/__${var}__/$ENV{$var}/g; } |
228 | } |
229 | |
230 | # Extra parameters |
231 | if ($param =~ /^ExtraSectionName(\d+)/) { $ExtraName[$1]=$value; next; } |
232 | |
233 | # Plugins |
234 | if ( $param =~ /^LoadPlugin/ ) { push @PluginsToLoad, $value; next; } |
235 | |
236 | # If parameters was not found previously, defined variable with name of param to value |
237 | $$param=$value; |
238 | } |
239 | |
240 | if ($Debug) { debug("Config file read was \"$configFile\" (level $level)"); } |
241 | } |
242 | |
243 | |
244 | |
245 | |
246 | #------------------------------------------------------------------------------ |
247 | # MAIN |
248 | #------------------------------------------------------------------------------ |
249 | ($DIR=$0) =~ s/([^\/\\]*)$//; ($PROG=$1) =~ s/\.([^\.]*)$//; $Extension=$1; |
250 | |
251 | my $QueryString=''; for (0..@ARGV-1) { $QueryString .= "$ARGV[$_]&"; } |
252 | |
253 | if ($QueryString =~ /(^|-|&)month=(year)/i) { error("month=year is a deprecated option. Use month=all instead."); } |
254 | |
255 | if ($QueryString =~ /(^|-|&)debug=(\d+)/i) { $Debug=$2; } |
256 | if ($QueryString =~ /(^|-|&)configdir=([^&]+)/i) { $DirConfig="$2"; } |
257 | if ($QueryString =~ /(^|-|&)config=([^&]+)/i) { $SiteConfig="$2"; } |
258 | if ($QueryString =~ /(^|-|&)databasebreak=([^&]+)/i) { $DatabaseBreak="$2"; } |
259 | if ($QueryString =~ /(^|-|&)awstatsprog=([^&]+)/i) { $Awstats="$2"; } |
260 | if ($QueryString =~ /(^|-|&)buildpdf/i) { $BuildPDF=1; } |
261 | if ($QueryString =~ /(^|-|&)buildpdf=([^&]+)/i) { $HtmlDoc="$2"; } |
262 | if ($QueryString =~ /(^|-|&)staticlinksext=([^&]+)/i) { $StaticExt="$2"; } |
263 | if ($QueryString =~ /(^|-|&)dir=([^&]+)/i) { $OutputDir="$2"; } |
264 | if ($QueryString =~ /(^|-|&)diricons=([^&]+)/i) { $DirIcons="$2"; } |
265 | if ($QueryString =~ /(^|-|&)update/i) { $Update=1; } |
266 | if ($QueryString =~ /(^|-|&)builddate=?([^&]*)/i) { $BuildDate=$2||'%YY%MM%DD'; } |
267 | if ($QueryString =~ /(^|-|&)year=(\d\d\d\d)/i) { $YearRequired="$2"; } |
268 | if ($QueryString =~ /(^|-|&)month=(\d{1,2})/i || $QueryString =~ /(^|-|&)month=(all)/i) { $MonthRequired="$2"; } |
269 | if ($QueryString =~ /(^|-|&)day=(\d{1,2})/i) { $DayRequired="$2"; } |
270 | |
271 | if ($QueryString =~ /(^|-|&)lang=([^&]+)/i) { $Lang="$2"; } |
272 | |
273 | if ($OutputDir) { if ($OutputDir !~ /[\\\/]$/) { $OutputDir.="/"; } } |
274 | |
275 | if (! $SiteConfig) { |
276 | print "----- $PROG $VERSION (c) Laurent Destailleur -----\n"; |
277 | print "$PROG allows you to launch AWStats with -staticlinks option\n"; |
278 | print "to build all possible pages allowed by AWStats -output option.\n"; |
279 | print "\n"; |
280 | print "Usage:\n"; |
281 | print "$PROG.$Extension (awstats_options) [awstatsbuildstaticpages_options]\n"; |
282 | print "\n"; |
283 | print " where awstats_options are any option known by AWStats\n"; |
284 | print " -config=configvalue is value for -config parameter (REQUIRED)\n"; |
285 | print " -update option used to update statistics before to generate pages\n"; |
286 | print " -lang=LL to output a HTML report in language LL (en,de,es,fr,...)\n"; |
287 | print " -month=MM to output a HTML report for an old month=MM\n"; |
288 | print " -year=YYYY to output a HTML report for an old year=YYYY\n"; |
289 | print "\n"; |
290 | print " and awstatsbuildstaticpages_options can be\n"; |
291 | print " -awstatsprog=pathtoawstatspl AWStats software (awstats.pl) path\n"; |
292 | print " -dir=outputdir Output directory for generated pages\n"; |
293 | print " -diricons=icondir Relative path to use as icon dir in <img> links\n"; |
294 | print " -builddate=%YY%MM%DD Used to add build date in built pages filenames\n"; |
295 | print " -staticlinksext=xxx Build pages with .xxx extension (default .html)\n"; |
296 | print " -buildpdf[=pathtohtmldoc] Build a PDF file after building HTML pages.\n"; |
297 | print " Output directory must contains icon directory\n"; |
298 | print " when this option is used (need 'htmldoc')\n"; |
299 | print "\n"; |
300 | print "New versions and FAQ at http://awstats.sourceforge.net\n"; |
301 | exit 0; |
302 | } |
303 | |
304 | |
305 | my $retour; |
306 | |
307 | # Check if AWSTATS prog is found |
308 | my $AwstatsFound=0; |
309 | if (-s "$Awstats") { $AwstatsFound=1; } |
310 | elsif (-s "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl") { |
311 | $Awstats="/usr/local/awstats/wwwroot/cgi-bin/awstats.pl"; |
312 | $AwstatsFound=1; |
313 | } |
314 | if (! $AwstatsFound) { |
315 | error("Can't find AWStats program ('$Awstats').\nUse -awstatsprog option to solve this"); |
316 | exit 1; |
317 | } |
318 | $AwstatsDir=$Awstats; $AwstatsDir =~ s/[\\\/][^\\\/]*$//; |
319 | debug("AwstatsDir=$AwstatsDir"); |
320 | |
321 | # Check if HTMLDOC prog is found |
322 | if ($BuildPDF) { |
323 | my $HtmlDocFound=0; |
324 | if (-x "$HtmlDoc") { $HtmlDocFound=1; } |
325 | elsif (-x "/usr/bin/htmldoc") { |
326 | $HtmlDoc='/usr/bin/htmldoc'; |
327 | $HtmlDocFound=1; |
328 | } |
329 | if (! $HtmlDocFound) { |
330 | error("Can't find htmldoc program ('$HtmlDoc').\nUse -buildpdf=htmldocprog option to solve this"); |
331 | exit 1; |
332 | } |
333 | } |
334 | |
335 | # Read config file (SiteConfig must be defined) |
336 | &Read_Config($DirConfig); |
337 | |
338 | if ($BuildReportFormat eq 'xhtml') { |
339 | $StaticExt="xml"; |
340 | if ($BuildPDF) { |
341 | error("Building PDF file is not compatible with building xml output files. Change your parameter BuildReportFormat to html in your config file"); |
342 | } |
343 | } |
344 | |
345 | # Define list of output files |
346 | if ($ShowDomainsStats) { push @OutputList,'alldomains'; } |
347 | if ($ShowHostsStats) { push @OutputList,'allhosts'; push @OutputList,'lasthosts'; push @OutputList,'unknownip'; } |
348 | if ($ShowAuthenticatedUsers) { push @OutputList,'alllogins'; push @OutputList,'lastlogins'; } |
349 | if ($ShowRobotsStats) { push @OutputList,'allrobots'; push @OutputList,'lastrobots'; } |
350 | if ($ShowEMailSenders) { push @OutputList,'allemails'; push @OutputList,'lastemails'; } |
351 | if ($ShowEMailReceivers) { push @OutputList,'allemailr'; push @OutputList,'lastemailr'; } |
352 | if ($ShowSessionsStats) { push @OutputList,'session'; } |
353 | if ($ShowPagesStats) { push @OutputList,'urldetail'; push @OutputList,'urlentry'; push @OutputList,'urlexit'; } |
354 | #if ($ShowFileTypesStats) { push @OutputList,'filetypes'; } # There is dedicated page for filetypes |
355 | if ($ShowOSStats) { push @OutputList,'osdetail'; push @OutputList,'unknownos'; } |
356 | if ($ShowBrowsersStats) { push @OutputList,'browserdetail'; push @OutputList,'unknownbrowser'; } |
357 | if ($ShowScreenSizeStats) { push @OutputList,'screensize'; } |
358 | if ($ShowOriginStats) { push @OutputList,'refererse'; push @OutputList,'refererpages'; } |
359 | if ($ShowKeyphrasesStats) { push @OutputList,'keyphrases'; } |
360 | if ($ShowKeywordsStats) { push @OutputList,'keywords'; } |
361 | #if ($ShowMiscStats) { push @OutputList,'misc'; } # There is no dedicated page for misc |
362 | if ($ShowHTTPErrorsStats) { |
363 | #push @OutputList,'errors'; # There is no dedicated page for errors |
364 | push @OutputList,'errors404'; |
365 | } |
366 | #if ($ShowSMTPErrorsStats) { push @OutputList,'errors'; } |
367 | foreach my $extranum (1..@ExtraName-1) { |
368 | push @OutputList,'allextra'.$extranum; |
369 | } |
370 | #Add plugins |
371 | foreach ( @PluginsToLoad ) { |
372 | if ($_ =~ /^(geoip_[_a-z]+)\s/) { push @OutputList,'plugin_'.$1; } # Add geoip maxmind subpages |
373 | } |
374 | |
375 | |
376 | # Launch awstats update |
377 | if ($Update) { |
378 | my $command="\"$Awstats\" -config=$SiteConfig -update"; |
379 | $command .= " -configdir=$DirConfig" if defined $DirConfig; |
380 | $command .= " -databasebreak=$DatabaseBreak" if defined $DatabaseBreak; |
381 | print "Launch update process : $command\n"; |
382 | $retour=`$command 2>&1`; |
383 | } |
384 | |
385 | # Built the OutputSuffix value (used later to build page name) |
386 | $OutputSuffix=$SiteConfig; |
387 | if ($BuildDate) { |
388 | ($nowsec,$nowmin,$nowhour,$nowday,$nowmonth,$nowyear,$nowwday,$nowyday) = localtime(time); |
389 | $nowweekofmonth=int($nowday/7); |
390 | $nowweekofyear=int(($nowyday-1+6-($nowwday==0?6:$nowwday-1))/7)+1; if ($nowweekofyear > 52) { $nowweekofyear = 1; } |
391 | $nowdaymod=$nowday%7; |
392 | $nowwday++; |
393 | $nowns=Time::Local::timegm(0,0,0,$nowday,$nowmonth,$nowyear); |
394 | if ($nowdaymod <= $nowwday) { if (($nowwday != 7) || ($nowdaymod != 0)) { $nowweekofmonth=$nowweekofmonth+1; } } |
395 | if ($nowdaymod > $nowwday) { $nowweekofmonth=$nowweekofmonth+2; } |
396 | # Change format of time variables |
397 | $nowweekofmonth="0$nowweekofmonth"; |
398 | if ($nowweekofyear < 10) { $nowweekofyear = "0$nowweekofyear"; } |
399 | if ($nowyear < 100) { $nowyear+=2000; } else { $nowyear+=1900; } |
400 | $nowsmallyear=$nowyear;$nowsmallyear =~ s/^..//; |
401 | if (++$nowmonth < 10) { $nowmonth = "0$nowmonth"; } |
402 | if ($nowday < 10) { $nowday = "0$nowday"; } |
403 | if ($nowhour < 10) { $nowhour = "0$nowhour"; } |
404 | if ($nowmin < 10) { $nowmin = "0$nowmin"; } |
405 | if ($nowsec < 10) { $nowsec = "0$nowsec"; } |
406 | # Replace tag with new value |
407 | $BuildDate =~ s/%YYYY/$nowyear/ig; |
408 | $BuildDate =~ s/%YY/$nowsmallyear/ig; |
409 | $BuildDate =~ s/%MM/$nowmonth/ig; |
410 | #$BuildDate =~ s/%MO/$MonthNumLibEn{$nowmonth}/ig; |
411 | $BuildDate =~ s/%DD/$nowday/ig; |
412 | $BuildDate =~ s/%HH/$nowhour/ig; |
413 | $BuildDate =~ s/%NS/$nowns/ig; |
414 | $BuildDate =~ s/%WM/$nowweekofmonth/g; |
415 | my $nowweekofmonth0=$nowweekofmonth-1; $BuildDate =~ s/%Wm/$nowweekofmonth0/g; |
416 | $BuildDate =~ s/%WY/$nowweekofyear/g; |
417 | my $nowweekofyear0=sprintf("%02d",$nowweekofyear-1); $BuildDate =~ s/%Wy/$nowweekofyear0/g; |
418 | $BuildDate =~ s/%DW/$nowwday/g; |
419 | my $nowwday0=$nowwday-1; $BuildDate =~ s/%Dw/$nowwday0/g; |
420 | $OutputSuffix.=".$BuildDate"; |
421 | } |
422 | |
423 | my $cpt=0; |
424 | my $NoLoadPlugin=""; |
425 | if ($BuildPDF) { $NoLoadPlugin.="tooltips,rawlog,hostinfo"; } |
426 | my $smallcommand="\"$Awstats\" -config=$SiteConfig".($BuildPDF?" -buildpdf":"").($NoLoadPlugin?" -noloadplugin=$NoLoadPlugin":"")." -staticlinks".($OutputSuffix ne $SiteConfig?"=$OutputSuffix":""); |
427 | if ($StaticExt && $StaticExt ne 'html') { $smallcommand.=" -staticlinksext=$StaticExt"; } |
428 | if ($DirIcons) { $smallcommand.=" -diricons=$DirIcons"; } |
429 | if ($DirConfig) { $smallcommand.=" -configdir=$DirConfig"; } |
430 | if ($Lang) { $smallcommand.=" -lang=$Lang"; } |
431 | if ($DayRequired) { $smallcommand.=" -day=$DayRequired"; } |
432 | if ($MonthRequired) { $smallcommand.=" -month=$MonthRequired"; } |
433 | if ($YearRequired) { $smallcommand.=" -year=$YearRequired"; } |
434 | |
435 | # Launch main awstats output |
436 | my $command="$smallcommand -output"; |
437 | print "Build main page: $command\n"; |
438 | $retour=`$command 2>&1`; |
439 | $OutputFile=($OutputDir?$OutputDir:"")."awstats.$OutputSuffix.$StaticExt"; |
440 | open("OUTPUT",">$OutputFile") || error("Couldn't open log file \"$OutputFile\" for writing : $!"); |
441 | print OUTPUT $retour; |
442 | close("OUTPUT"); |
443 | $cpt++; |
444 | push @pages, $OutputFile; # Add page to @page for PDF build |
445 | |
446 | # Launch all other awstats output |
447 | for my $output (@OutputList) { |
448 | my $command="$smallcommand -output=$output"; |
449 | print "Build $output page: $command\n"; |
450 | $retour=`$command 2>&1`; |
451 | $OutputFile=($OutputDir?$OutputDir:"")."awstats.$OutputSuffix.$output.$StaticExt"; |
452 | open("OUTPUT",">$OutputFile") || error("Couldn't open log file \"$OutputFile\" for writing : $!"); |
453 | print OUTPUT $retour; |
454 | close("OUTPUT"); |
455 | $cpt++; |
456 | push @pages, $OutputFile; # Add page to @page for PDF build |
457 | } |
458 | |
459 | # Build pdf file |
460 | if ($QueryString =~ /(^|-|&)buildpdf/i) { |
461 | # my $pdffile=$pages[0]; $pdffile=~s/\.\w+$/\.pdf/; |
462 | $OutputFile=($OutputDir?$OutputDir:"")."awstats.$OutputSuffix.pdf"; |
463 | my $command="\"$HtmlDoc\" -t pdf --webpage --quiet --no-title --textfont helvetica --left 16 --bottom 8 --top 8 --browserwidth 800 --headfootsize 8.0 --fontsize 7.0 --header xtx --footer xd/ --outfile $OutputFile @pages\n"; |
464 | print "Build PDF file : $command\n"; |
465 | $retour=`$command 2>&1`; |
466 | my $signal_num=$? & 127; |
467 | my $dumped_core=$? & 128; |
468 | my $exit_value=$? >> 8; |
469 | if ($? || $retour =~ /error/) { |
470 | if ($retour) { error("Failed to build PDF file with following error: $retour"); } |
471 | else { error("Failed to run successfuly htmldoc process: Return code=$exit_value, Killer signal num=$signal_num, Core dump=$dumped_core"); } |
472 | } |
473 | $cpt++; |
474 | } |
475 | |
476 | |
477 | print "$cpt files built.\n"; |
478 | print "Main HTML page is 'awstats.$OutputSuffix.$StaticExt'.\n"; |
479 | if ($QueryString =~ /(^|-|&)buildpdf/i) { print "PDF file is 'awstats.$OutputSuffix.pdf'.\n"; } |
480 | |
481 | 0; # Do not remove this line |