From: eldy <> Date: Sat, 19 Jan 2002 20:00:02 +0000 (+0000) Subject: Added option -staticlinks to build static links in report page (to use AWStats with... X-Git-Tag: AWSTATS_4_0_BETA~142 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a615f8eaa456e5335ba3471cfb528af9eb096927;p=thirdparty%2FAWStats.git Added option -staticlinks to build static links in report page (to use AWStats with no web servers). --- diff --git a/wwwroot/cgi-bin/awstats.pl b/wwwroot/cgi-bin/awstats.pl index 1eb6486c..b3470d1c 100644 --- a/wwwroot/cgi-bin/awstats.pl +++ b/wwwroot/cgi-bin/awstats.pl @@ -54,8 +54,8 @@ $MinHitLogin, $MinHitRefer, $MinHitRobot, $NbOfLinesForCorruptedLog, $ShowAuthenticatedUsers, $ShowCompressionStats, $ShowFileSizesStats, $ShowCorrupted, $ShowSteps, $StartSeconds, $StartMicroseconds, -$URLWithQuery)= -(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); +$StaticLinks, $URLWithQuery)= +(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); ($ArchiveLogRecords, $DetailedReportsOnNewWindows, $FirstDayOfWeek, $ShowHeader, $ShowMenu, $ShowMonthDayStats, $ShowDaysOfWeekStats, $ShowHoursStats, $ShowDomainsStats, $ShowHostsStats, @@ -72,7 +72,7 @@ $LastUpdate, $LogFile, $LogFormat, $LogFormatString, $Logo, $LogoLink, $MonthRequired, $HTMLOutput, $PROG, $PageCode, $PurgeLogFile, $QueryString, -$SiteConfig, $SiteDomain, $SiteToAnalyze, $SiteToAnalyzeWithoutwww, $Sort, +$SiteConfig, $SiteDomain, $SiteToAnalyze, $SiteToAnalyzeWithoutwww, $TotalEntries, $TotalBytesPages, $TotalDifferentPages, $URLFilter, $UserAgent, $YearRequired)= (); ($color_Background, $color_TableBG, $color_TableBGRowTitle, @@ -126,7 +126,7 @@ $color_h, $color_k, $color_p, $color_s, $color_u, $color_v)= -$VERSION="4.0 (build 8)"; +$VERSION="4.0 (build 9)"; $Lang="en"; # Default value @@ -1490,10 +1490,10 @@ sub Read_History_File { my $count=0;my $countloaded=0; while ($field[0] ne "END_SIDER_404") { $count++; - if ($part && ($UpdateStats || $QueryString !~ /output=/i || $QueryString =~ /output=notfounderror/i)) { + if ($part && ($UpdateStats || $QueryString !~ /output=/i || $QueryString =~ /output=errors404/i)) { $countloaded++; if ($field[1]) { $_sider404_h{$field[0]}+=$field[1]; } - if ($UpdateStats || $QueryString =~ /output=notfounderror/i) { + if ($UpdateStats || $QueryString =~ /output=errors404/i) { if ($field[2]) { $_referer404_h{$field[0]}=$field[2]; } } } @@ -1780,6 +1780,7 @@ sub Show_Flag_Links { my $NewLinkParams=$QueryString; if ($ENV{"GATEWAY_INTERFACE"}) { $NewLinkParams =~ s/update[=]*[^ &]*//; + $NewLinkParams =~ s/staticlinks[=]*[^ &]*//; $NewLinkParams =~ s/lang=[^ &]*//; $NewLinkParams =~ tr/&/&/s; $NewLinkParams =~ s/^&//; $NewLinkParams =~ s/&$//; if ($NewLinkParams) { $NewLinkParams="${NewLinkParams}&"; } @@ -2033,8 +2034,8 @@ else { # Run from command line if ($QueryString =~ /showcorrupted/i) { $ShowCorrupted=1; } else { $ShowCorrupted=0; } $QueryString=~s/showcorrupted[^&]*//; } -if ($QueryString =~ /sort=/i) { $Sort=$QueryString; $Sort =~ s/.*sort=//i; $Sort =~ s/&.*//; $Sort =~ s/ .*//; } -if ($QueryString =~ /debug=/i) { $Debug=$QueryString; $Debug =~ s/.*debug=//i; $Debug =~ s/&.*//; $Debug =~ s/ .*//; } +if ($QueryString =~ /staticlinks/i) { $StaticLinks=1; } +if ($QueryString =~ /debug=(\d+)/i) { $Debug=$1; } if ($QueryString =~ /output=urldetail:/i) { # A filter can be defined with output=urldetail to reduce number of lines read and showed $URLFilter=$QueryString; $URLFilter =~ s/.*output=urldetail://; $URLFilter =~ s/&.*//; $URLFilter =~ s/ .*//; @@ -2065,14 +2066,24 @@ if ((! $ENV{"GATEWAY_INTERFACE"}) && (! $SiteConfig)) { print "Options to update statistics:\n"; print " -update to update statistics (default)\n"; print " -showsteps to add benchmark information every $NbOfLinesForBenchmark lines processed\n"; - print " -showcorrupted to add output for each corrupted lines found with reason\n"; + print " -showcorrupted to add output for each corrupted lines found, with reason\n"; print " Be care to process log files in chronological order when updating statistics.\n"; print "\n"; print "Options to show statistics:\n"; - print " -output to output a HTML report (no update made except if -update is set)\n"; - print " -lang=LL to output a HTML report in language LL (en,de,es,fr,it,nl,...)\n"; - print " -month=MM to output a HTML report for an old month=MM\n"; - print " -year=YYYY to output a HTML report for an old year=YYYY\n"; + print " -output to output main HTML report (no update made except with -update)\n"; + print " -output=x to output other report pages where x is:\n"; + print " lasthosts to build page of last connections\n"; + print " unknownip to build page of all unresolved IP\n"; + print " urldetail to list most often viewed pages \n"; + print " urldetail:filter to list most often viewed pages matching filter\n"; + print " unknownreferer to list 'User Agents' with unknown OS\n"; + print " unknownrefererbrowser to list 'User Agents' with unknown browser\n"; + print " browserdetail to build page with browsers detailed versions\n"; + print " errors404 to list 'Referers' for 404 errors\n"; + print " -staticlinks to have static links in HTML report page\n"; + print " -lang=LL to output a HTML report in language LL (en,de,es,fr,it,nl,...)\n"; + print " -month=MM to output a HTML report for an old month=MM\n"; + print " -year=YYYY to output a HTML report for an old year=YYYY\n"; print " Warning: Those 'date' options doesn't allow you to process old log file.\n"; print " It only allows you to see a report for a chosen month/year period instead\n"; print " of current month/year.\n"; @@ -3192,16 +3203,13 @@ if ($HTMLOutput) { EOF - # Define the LinkParamA and LinkParamB for main chart - my $LinkParamA=""; my $LinkParamB=""; + # Define the NewLinkParams for main chart my $NewLinkParams=${QueryString}; $NewLinkParams =~ s/update[=]*[^ &]*//; $NewLinkParams =~ s/output[=]*[^ &]*//; + $NewLinkParams =~ s/staticlinks[=]*[^ &]*//; $NewLinkParams =~ tr/&/&/s; $NewLinkParams =~ s/^&//; $NewLinkParams =~ s/&$//; - if ($NewLinkParams) { - $LinkParamA="?$NewLinkParams"; - $LinkParamB="$NewLinkParams&"; - } + if ($NewLinkParams) { $NewLinkParams="${NewLinkParams}&"; } # FirstTime LastTime TotalVisits TotalUnique TotalHostsKnown TotalHostsUnknown my $FirstTime=$LastTime=$TotalUnique=$TotalVisits=$TotalHostsKnown=$TotalHostsUnKnown=0; @@ -3274,6 +3282,7 @@ EOF if ($AllowToUpdateStatsFromBrowser) { my $NewLinkParams=${QueryString}; $NewLinkParams =~ s/update[=]*[^ &]*//; + $NewLinkParams =~ s/staticlinks[=]*[^ &]*//; $NewLinkParams =~ tr/&/&/s; $NewLinkParams =~ s/^&//; $NewLinkParams =~ s/&$//; if ($NewLinkParams) { $NewLinkParams="${NewLinkParams}&"; } print "$Message[74]"; @@ -3284,44 +3293,46 @@ EOF # When print "$Message[93] : "; print ""; - if ($ShowMonthDayStats) { print "$Message[5]/$Message[4]   "; } - if ($ShowDaysOfWeekStats) { print "$Message[91]   "; } - if ($ShowHoursStats) { print "$Message[20]   "; } +# if ($ShowMonthDayStats) { print "$Message[5]/$Message[4]   "; } + if ($ShowMonthDayStats) { print "$Message[5]/$Message[4]   "; } + if ($ShowDaysOfWeekStats) { print "$Message[91]   "; } + if ($ShowHoursStats) { print "$Message[20]   "; } # Who print "$Message[92] : "; print ""; - if ($ShowDomainsStats) { print "$Message[17]   "; } - if ($ShowHostsStats) { print "".ucfirst($Message[81])."   "; } - if ($ShowHostsStats) { print "$Message[9]  \n"; } - if ($ShowHostsStats) { print "$Message[45]  \n"; } - if ($ShowAuthenticatedUsers) { print "$Message[94]   "; } - if ($ShowRobotsStats) { print "$Message[53]   "; } + if ($ShowDomainsStats) { print "$Message[17]   "; } + if ($ShowHostsStats) { print "".ucfirst($Message[81])."   "; } + if ($ShowHostsStats) { print "$Message[9]  \n"; } + if ($ShowHostsStats) { print "$Message[45]  \n"; } + if ($ShowAuthenticatedUsers) { print "$Message[94]   "; } + if ($ShowRobotsStats) { print "$Message[53]   "; } print "
"; # Navigation print "$Message[72] : "; print ""; - if ($ShowPagesStats) { print "$Message[29]   "; } - if ($ShowPagesStats) { print "$Message[104]   "; } - if ($ShowFileTypesStats) { print "$Message[73]   "; } + if ($ShowPagesStats) { print "$Message[29]   "; } + if ($ShowPagesStats) { print "$Message[104]   "; } + if ($ShowFileTypesStats) { print "$Message[73]   "; } if ($ShowFileSizesStats) { } - if ($ShowOSStats) { print "$Message[59]   "; } - if ($ShowBrowsersStats) { print "$Message[21]   "; } - if ($ShowBrowsersStats) { print "$Message[33]   "; } - if ($ShowBrowsersStats) { print "$Message[34]
\n"; } + if ($ShowOSStats) { print "$Message[59]   "; } + if ($ShowBrowsersStats) { print "$Message[21]   "; } + if ($ShowBrowsersStats) { print "$Message[33]   "; } + if ($ShowBrowsersStats) { print "$Message[34]
\n"; } # Referers print "$Message[23] : "; print ""; - if ($ShowOriginStats) { print "$Message[37]   "; } - if ($ShowKeyphrasesStats) { print "$Message[24]
\n"; } + if ($ShowOriginStats) { print "$Message[37]   "; } + if ($ShowKeyphrasesStats) { print "$Message[24]
\n"; } # Others print "$Message[2] : "; print ""; - if ($ShowCompressionStats) { print "$Message[98]   "; } - if ($ShowHTTPErrorsStats) { print "$Message[22]   "; } - if ($ShowHTTPErrorsStats) { print "$Message[31]
\n"; } + if ($ShowCompressionStats) { print "$Message[98]   "; } + if ($ShowHTTPErrorsStats) { print "$Message[22]   "; } + if ($ShowHTTPErrorsStats) { print "$Message[31]
\n"; } } else { - if ($ShowBackLink) { print "$Message[76]\n"; } + ${NewLinkParams} =~ s/&+$//; + if ($ShowBackLink) { print "$Message[76]\n"; } } print "\n"; print "
\n"; @@ -3508,7 +3519,7 @@ EOF &html_end; exit(0); } - if ($QueryString =~ /output=notfounderror/i) { + if ($QueryString =~ /output=errors404/i) { print "$CENTER 
"; &tab_head($Message[47],19); print "URL (".(scalar keys %_sider404_h).")$Message[49]$Message[23]\n"; @@ -3548,10 +3559,13 @@ EOF $NewLinkParams =~ s/update[=]*[^ &]*//; $NewLinkParams =~ s/year=[^ &]*//; $NewLinkParams =~ s/month=[^ &]*//; + $NewLinkParams =~ s/staticlinks[=]*[^ &]*//; $NewLinkParams =~ tr/&/&/s; $NewLinkParams =~ s/^&//; $NewLinkParams =~ s/&$//; if ($NewLinkParams) { $NewLinkParams="${NewLinkParams}&"; } foreach my $key (sort keys %listofyears) { - print "$Message[6] $key   "; + if ($ENV{"GATEWAY_INTERFACE"} || !$StaticLinks) { + print "$Message[6] $key   "; + } } print ""; print "$Message[9]\n"; @@ -3615,7 +3629,11 @@ EOF print ""; for (my $ix=1; $ix<=12; $ix++) { my $monthix=$ix; if ($monthix < 10) { $monthix="0$monthix"; } - print "$monthlib{$monthix}\n"; + print ""; + if ($ENV{"GATEWAY_INTERFACE"} || !$StaticLinks) { print ""; } + print "$monthlib{$monthix}"; + if ($ENV{"GATEWAY_INTERFACE"} || !$StaticLinks) { print ""; } + print "\n"; } print "\n"; print "\n
\n"; @@ -3868,7 +3886,7 @@ EOF debug("ShowHostsStats",2); print "$CENTER 
"; $MaxNbOfHostsShown = (scalar keys %_hostmachine_h) if $MaxNbOfHostsShown > (scalar keys %_hostmachine_h); - &tab_head("$Message[81] ($Message[77] $MaxNbOfHostsShown)   -   $Message[9]   -   $Message[45]",19); + &tab_head("$Message[81] ($Message[77] $MaxNbOfHostsShown)   -   $Message[9]   -   $Message[45]",19); if ($MonthRequired ne "year") { print "$Message[81] : $TotalHostsKnown $Message[82], $TotalHostsUnknown $Message[1] - $TotalUnique $Message[11]$Message[56]$Message[57]$Message[75]$Message[9]\n"; } else { print "$Message[81] : ".(scalar keys %_hostmachine_h)."$Message[56]$Message[57]$Message[75]$Message[9]\n"; } $total_p=$total_h=$total_k=0; @@ -3955,7 +3973,7 @@ EOF debug("ShowPagesStats (MaxNbOfPageShown=$MaxNbOfPageShown TotalDifferentPages=$TotalDifferentPages)",2); print "$CENTER  
"; $MaxNbOfPageShown = $TotalDifferentPages if $MaxNbOfPageShown > $TotalDifferentPages; - &tab_head("$Message[19] ($Message[77] $MaxNbOfPageShown)   -   $Message[80]",19); + &tab_head("$Message[19] ($Message[77] $MaxNbOfPageShown)   -   $Message[80]",19); print "$TotalDifferentPages $Message[28]"; print "$Message[29]"; print "$Message[104]"; @@ -4070,8 +4088,8 @@ EOF if ($ShowBrowsersStats) { debug("ShowBrowsersStats",2); print "$CENTER 
"; - $BrowsersHashIDLib{"netscape"}="Netscape ($Message[58])"; - $BrowsersHashIDLib{"msie"}="MS Internet Explorer ($Message[58])"; + $BrowsersHashIDLib{"netscape"}="Netscape ($Message[58])"; + $BrowsersHashIDLib{"msie"}="MS Internet Explorer ($Message[58])"; my $Total=0; foreach my $key (keys %_browser_h) { $Total+=$_browser_h{$key}; } &tab_head($Message[21],19); print "Browser$Message[57]$Message[15]\n"; @@ -4079,7 +4097,7 @@ EOF foreach my $key (sort { $_browser_h{$b} <=> $_browser_h{$a} } keys (%_browser_h)) { my $p=int($_browser_h{$key}/$Total*1000)/10; if ($key eq "Unknown") { - print "$Message[0]$_browser_h{$key}$p %\n"; + print "$Message[0]$_browser_h{$key}$p %\n"; } else { my $newbrowser=$BrowsersHashIDLib{$key}||$key; @@ -4102,7 +4120,7 @@ EOF foreach my $key (sort { $_os_h{$b} <=> $_os_h{$a} } keys (%_os_h)) { my $p=int($_os_h{$key}/$Total*1000)/10; if ($key eq "Unknown") { - print "$Message[0]$_os_h{$key}"; + print "$Message[0]$_os_h{$key}"; print "$p %\n"; } else { @@ -4225,7 +4243,7 @@ EOF my $p=int($_errors_h{$key}/$TotalErrors*1000)/10; if ($httpcode{$key}) { print ""; } else { print ""; } - if ($key == 404) { print "$key"; } + if ($key == 404) { print "$key"; } else { print "$key"; } if ($httpcode{$key}) { print "$httpcode{$key}$_errors_h{$key}$p %\n"; } else { print "Unknown error$_errors_h{$key}$p %\n"; }