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