Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » PHP Development Tools (PDT) » Editing non PHP file
Editing non PHP file [message #86775] Sat, 13 December 2008 15:36
Marko Karjalainen is currently offline Marko KarjalainenFriend
Messages: 30
Registered: July 2009
Member
This is a multi-part message in MIME format.
--------------070406090305000506050706
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

Can someone test if this is bug in 2.0 RC1 (and olders)?

1. Go Preferences / General / Content Type, Add *.pl filetypes to PHP Content Type
2. Open attached file (awstats.pl) and goto line 586 add comment char '#' to begin of line
# else { print "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"; };

CPU usage of eclipse.exe goes 100% and must be killed from process list.

--------------070406090305000506050706
Content-Type: text/plain;
name="awstats.pl"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment;
filename="awstats.pl"

#!/usr/bin/perl
#----------------------------------------------------------- -------------------
# Free realtime web server logfile analyzer to show advanced web statistics.
# Works from command line or as a CGI. You must use this script as often as
# necessary from your scheduler to update your statistics and from command
# line or a browser to read report results.
# See AWStats documentation (in docs/ directory) for all setup instructions.
#----------------------------------------------------------- -------------------
# $Revision: 1.1 $ - $Author: markarj $ - $Date: 2008/08/04 08:40:32 $
require 5.005;

#$|=1;
#use warnings; # Must be used in test mode only. This reduce a little process speed
#use diagnostics; # Must be used in test mode only. This reduce a lot of process speed
use strict;no strict "refs";
use Time::Local; # use Time::Local 'timelocal_nocheck' is faster but not supported by all Time::Local modules
use Socket;


#----------------------------------------------------------- -------------------
# Defines
#----------------------------------------------------------- -------------------
use vars qw/ $REVISION $VERSION /;
$REVISION='$Revision: 1.1 $'; $REVISION =~ /\s(.*)\s/; $REVISION=$1;
$VERSION="6.8 (build $REVISION)";

# ----- Constants -----
use vars qw/
$DEBUGFORCED $NBOFLINESFORBENCHMARK $FRAMEWIDTH $NBOFLASTUPDATELOOKUPTOSAVE
$LIMITFLUSH $NEWDAYVISITTIMEOUT $VISITTIMEOUT $NOTSORTEDRECORDTOLERANCE
$WIDTHCOLICON $TOOLTIPON
$lastyearbeforeupdate $lastmonthbeforeupdate $lastdaybeforeupdate $lasthourbeforeupdate $lastdatebeforeupdate
/;
$DEBUGFORCED=0; # Force debug level to log lesser level into debug.log file (Keep this value to 0)
$NBOFLINESFORBENCHMARK=8192; # Benchmark info are printing every NBOFLINESFORBENCHMARK lines (Must be a power of 2)
$FRAMEWIDTH=240; # Width of left frame when UseFramesWhenCGI is on
$NBOFLASTUPDATELOOKUPTOSAVE=500; # Nb of records to save in DNS last update cache file
$LIMITFLUSH=5000; # Nb of records in data arrays after how we need to flush data on disk
$NEWDAYVISITTIMEOUT=764041; # Delay between 01-23:59:59 and 02-00:00:00
$VISITTIMEOUT=10000; # Lapse of time to consider a page load as a new visit. 10000 = 1 hour (Default = 10000)
$NOTSORTEDRECORDTOLERANCE=20000; # Lapse of time to accept a record if not in correct order. 20000 = 2 hour (Default = 20000)
$WIDTHCOLICON=32;
$TOOLTIPON=0; # Tooltips plugin loaded
# ----- Running variables -----
use vars qw/
$DIR $PROG $Extension
$Debug $ShowSteps
$DebugResetDone $DNSLookupAlreadyDone
$RunAsCli $UpdateFor $HeaderHTTPSent $HeaderHTMLSent
$LastLine $LastLineNumber $LastLineOffset $LastLineChecksum $LastUpdate
$lowerval
$PluginMode
$MetaRobot
$TotalUnique $TotalVisits $TotalHostsKnown $TotalHostsUnknown
$TotalPages $TotalHits $TotalBytes
$TotalNotViewedPages $TotalNotViewedHits $TotalNotViewedBytes
$TotalEntries $TotalExits $TotalBytesPages $TotalDifferentPages
$TotalKeyphrases $TotalKeywords $TotalDifferentKeyphrases $TotalDifferentKeywords
$TotalSearchEnginesPages $TotalSearchEnginesHits $TotalRefererPages $TotalRefererHits $TotalDifferentSearchEngines $TotalDifferentReferer
$FrameName $Center $FileConfig $FileSuffix $Host $YearRequired $MonthRequired $DayRequired $HourRequired
$QueryString $SiteConfig $StaticLinks $PageCode $PageDir $PerlParsingFormat $UserAgent
$pos_vh $pos_host $pos_logname $pos_date $pos_tz $pos_method $pos_url $pos_code $pos_size
$pos_referer $pos_agent $pos_query $pos_gzipin $pos_gzipout $pos_compratio $pos_timetaken
$pos_cluster $pos_emails $pos_emailr $pos_hostr @pos_extra
/;
$DIR=$PROG=$Extension='';
$Debug = $ShowSteps = 0;
$DebugResetDone = $DNSLookupAlreadyDone = 0;
$RunAsCli = $UpdateFor = $HeaderHTTPSent = $HeaderHTMLSent = 0;
$LastLine = $LastLineNumber = $LastLineOffset = $LastLineChecksum = $LastUpdate = 0;
$lowerval = 0;
$PluginMode = '';
$MetaRobot = 0;
$TotalUnique = $TotalVisits = $TotalHostsKnown = $TotalHostsUnknown = 0;
$TotalPages = $TotalHits = $TotalBytes = 0;
$TotalNotViewedPages = $TotalNotViewedHits = $TotalNotViewedBytes = 0;
$TotalEntries = $TotalExits = $TotalBytesPages = $TotalDifferentPages = 0;
$TotalKeyphrases = $TotalKeywords = $TotalDifferentKeyphrases = $TotalDifferentKeywords = 0;
$TotalSearchEnginesPages = $TotalSearchEnginesHits = $TotalRefererPages = $TotalRefererHits = $TotalDifferentSearchEngines = $TotalDifferentReferer = 0;
($FrameName, $Center, $FileConfig, $FileSuffix, $Host, $YearRequired, $MonthRequired, $DayRequired, $HourRequired,
$QueryString, $SiteConfig, $StaticLinks, $PageCode, $PageDir, $PerlParsingFormat, $UserAgent)=
('','','','','','','','','','','','','','','','');
# ----- Plugins variable -----
use vars qw/ %PluginsLoaded $PluginDir $AtLeastOneSectionPlugin /;
%PluginsLoaded=();
$PluginDir='';
$AtLeastOneSectionPlugin=0;
# ----- Time vars -----
use vars qw/
$starttime
$nowtime $tomorrowtime
$nowweekofmonth $nowweekofyear $nowdaymod $nowsmallyear
$nowsec $nowmin $nowhour $nowday $nowmonth $nowyear $nowwday $nowyday $nowns
$StartSeconds $StartMicroseconds
/;
$StartSeconds=$StartMicroseconds=0;
# ----- Variables for config file reading -----
use vars qw/
$FoundNotPageList
/;
$FoundNotPageList=0;
# ----- Config file variables -----
use vars qw/
$StaticExt
$DNSStaticCacheFile
$DNSLastUpdateCacheFile
$MiscTrackerUrl
$Lang
$MaxRowsInHTMLOutput
$MaxLengthOfShownURL
$MaxLengthOfStoredURL
$MaxLengthOfStoredUA
%BarPng
$BuildReportFormat
$BuildHistoryFormat
$ExtraTrackedRowsLimit
$DatabaseBreak
$SectionsToBeSaved
/;
$StaticExt='html';
$DNSStaticCacheFile='dnscache.txt';
$DNSLastUpdateCacheFile='dnscachelastupdate.txt';
$MiscTrackerUrl='/js/awstats_misc_tracker.js';
$Lang='auto';
$SectionsToBeSaved='all';
$MaxRowsInHTMLOutput=1000;
$MaxLengthOfShownURL=64;
$MaxLengthOfStoredURL=256; # Note: Apache LimitRequestLine is default to 8190
$MaxLengthOfStoredUA=256;
%BarPng=('vv'=>'vv.png','vu'=>'vu.png','hu'=>'hu.png','vp'= >'vp.png','hp'=>'hp.png',
'he'=>'he.png','hx'=>'hx.png','vh'=>'vh.png','hh'=>'hh.png','vk'= >'vk.png','hk'=>'hk.png');
$BuildReportFormat='html';
$BuildHistoryFormat='text';
$ExtraTrackedRowsLimit=500;
$DatabaseBreak='month';
use vars qw/
$DebugMessages $AllowToUpdateStatsFromBrowser $EnableLockForUpdate $DNSLookup $AllowAccessFromWebToAuthenticatedUsersOnly
$BarHeight $BarWidth $CreateDirDataIfNotExists $KeepBackupOfHistoricFiles
$NbOfLinesParsed $NbOfLinesDropped $NbOfLinesCorrupted $NbOfOldLines $NbOfNewLines
$NbOfLinesShowsteps $NewLinePhase $NbOfLinesForCorruptedLog $PurgeLogFile $ArchiveLogRecords
$ShowDropped $ShowCorrupted $ShowUnknownOrigin $ShowDirectOrigin $ShowLinksToWhoIs
$ShowAuthenticatedUsers $ShowFileSizesStats $ShowScreenSizeStats $ShowSMTPErrorsStats
$ShowEMailSenders $ShowEMailReceivers $ShowWormsStats $ShowClusterStats
$IncludeInternalLinksInOriginSection
$AuthenticatedUsersNotCaseSensitive
$Expires $UpdateStats $MigrateStats $URLNotCaseSensitive $URLWithQuery $URLReferrerWithQuery
$DecodeUA
/;
($DebugMessages, $AllowToUpdateStatsFromBrowser, $EnableLockForUpdate, $DNSLookup, $AllowAccessFromWebToAuthenticatedUsersOnly,
$BarHeight, $BarWidth, $CreateDirDataIfNotExists, $KeepBackupOfHistoricFiles,
$NbOfLinesParsed, $NbOfLinesDropped, $NbOfLinesCorrupted, $NbOfOldLines, $NbOfNewLines,
$NbOfLinesShowsteps, $NewLinePhase, $NbOfLinesForCorruptedLog, $PurgeLogFile, $ArchiveLogRecords,
$ShowDropped, $ShowCorrupted, $ShowUnknownOrigin, $ShowDirectOrigin, $ShowLinksToWhoIs,
$ShowAuthenticatedUsers, $ShowFileSizesStats, $ShowScreenSizeStats, $ShowSMTPErrorsStats,
$ShowEMailSenders, $ShowEMailReceivers, $ShowWormsStats, $ShowClusterStats,
$IncludeInternalLinksInOriginSection,
$AuthenticatedUsersNotCaseSensitive,
$Expires, $UpdateStats, $MigrateStats, $URLNotCaseSensitive, $URLWithQuery, $URLReferrerWithQuery,
$DecodeUA)=
(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,0,0,0,0,0,0,0,0);
use vars qw/
$DetailedReportsOnNewWindows
$FirstDayOfWeek $KeyWordsNotSensitive $SaveDatabaseFilesWithPermissionsForEveryone
$WarningMessages $ShowLinksOnUrl $UseFramesWhenCGI
$ShowMenu $ShowSummary $ShowMonthStats $ShowDaysOfMonthStats $ShowDaysOfWeekStats
$ShowHoursStats $ShowDomainsStats $ShowHostsStats
$ShowRobotsStats $ShowSessionsStats $ShowPagesStats $ShowFileTypesStats
$ShowOSStats $ShowBrowsersStats $ShowOriginStats
$ShowKeyphrasesStats $ShowKeywordsStats $ShowMiscStats $ShowHTTPErrorsStats
$AddDataArrayMonthStats $AddDataArrayShowDaysOfMonthStats $AddDataArrayShowDaysOfWeekStats $AddDataArrayShowHoursStats
/;
($DetailedReportsOnNewWindows,
$FirstDayOfWeek, $KeyWordsNotSensitive, $SaveDatabaseFilesWithPermissionsForEveryone,
$WarningMessages, $ShowLinksOnUrl, $UseFramesWhenCGI,
$ShowMenu, $ShowSummary, $ShowMonthStats, $ShowDaysOfMonthStats, $ShowDaysOfWeekStats,
$ShowHoursStats, $ShowDomainsStats, $ShowHostsStats,
$ShowRobotsStats, $ShowSessionsStats, $ShowPagesStats, $ShowFileTypesStats,
$ShowOSStats, $ShowBrowsersStats, $ShowOriginStats,
$ShowKeyphrasesStats, $ShowKeywordsStats, $ShowMiscStats, $ShowHTTPErrorsStats,
$AddDataArrayMonthStats, $AddDataArrayShowDaysOfMonthStats, $AddDataArrayShowDaysOfWeekStats, $AddDataArrayShowHoursStats
)=
(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 ,1);
use vars qw/
$AllowFullYearView
$LevelForRobotsDetection $LevelForWormsDetection $LevelForBrowsersDetection $LevelForOSDetection $LevelForRefererAnalyze
$LevelForFileTypesDetection $LevelForSearchEnginesDetection $LevelForKeywordsDetection
/;
($AllowFullYearView,
$LevelForRobotsDetection, $LevelForWormsDetection, $LevelForBrowsersDetection, $LevelForOSDetection, $LevelForRefererAnalyze,
$LevelForFileTypesDetection, $LevelForSearchEnginesDetection, $LevelForKeywordsDetection)=
(2,2,0,2,2,2,2,2,2);
use vars qw/
$DirLock $DirCgi $DirConfig $DirData $DirIcons $DirLang $AWScript $ArchiveFileName
$AllowAccessFromWebToFollowingIPAddresses $HTMLHeadSection $HTMLEndSection $LinksToWhoIs $LinksToIPWhoIs
$LogFile $LogType $LogFormat $LogSeparator $Logo $LogoLink $StyleSheet $WrapperScript $SiteDomain
$UseHTTPSLinkForUrl $URLQuerySeparators $URLWithAnchor $ErrorMessages $ShowFlagLinks
/;
($DirLock, $DirCgi, $DirConfig, $DirData, $DirIcons, $DirLang, $AWScript, $ArchiveFileName,
$AllowAccessFromWebToFollowingIPAddresses, $HTMLHeadSection, $HTMLEndSection, $LinksToWhoIs, $LinksToIPWhoIs,
$LogFile, $LogType, $LogFormat, $LogSeparator, $Logo, $LogoLink, $StyleSheet, $WrapperScript, $SiteDomain,
$UseHTTPSLinkForUrl, $URLQuerySeparators, $URLWithAnchor, $ErrorMessages, $ShowFlagLinks)=
('','','','','','','','','','','','','','','','','','','','' ,'','','','','','','');
use vars qw/
$color_Background $color_TableBG $color_TableBGRowTitle
$color_TableBGTitle $color_TableBorder $color_TableRowTitle $color_TableTitle
$color_text $color_textpercent $color_titletext $color_weekend $color_link $color_hover $color_other
$color_h $color_k $color_p $color_e $color_x $color_s $color_u $color_v
/;
($color_Background, $color_TableBG, $color_TableBGRowTitle,
$color_TableBGTitle, $color_TableBorder, $color_TableRowTitle, $color_TableTitle,
$color_text, $color_textpercent, $color_titletext, $color_weekend, $color_link, $color_hover, $color_other,
$color_h, $color_k, $color_p, $color_e, $color_x, $color_s, $color_u, $color_v)=
('','','','','','','','','','','','','','','','','','','','' ,'','');
# ---------- Init arrays --------
use vars qw/
@RobotsSearchIDOrder_list1 @RobotsSearchIDOrder_list2 @RobotsSearchIDOrder_listgen
@SearchEnginesSearchIDOrder_list1 @SearchEnginesSearchIDOrder_list2 @SearchEnginesSearchIDOrder_listgen
@BrowsersSearchIDOrder @OSSearchIDOrder @WordsToExtractSearchUrl @WordsToCleanSearchUrl
@WormsSearchIDOrder
@RobotsSearchIDOrder @SearchEnginesSearchIDOrder
@_from_p @_from_h
@_time_p @_time_h @_time_k @_time_nv_p @_time_nv_h @_time_nv_k
@DOWIndex @fieldlib @keylist
/;
@RobotsSearchIDOrder = @SearchEnginesSearchIDOrder = ();
@_from_p = @_from_h = ();
@_time_p = @_time_h = @_time_k = @_time_nv_p = @_time_nv_h = @_time_nv_k = ();
@DOWIndex = @fieldlib = @keylist = ();
use vars qw/
@MiscListOrder %MiscListCalc
%OSFamily %BrowsersFamily @SessionsRange %SessionsAverage
%LangBrowserToLangAwstats %LangAWStatsToFlagAwstats
@HostAliases @AllowAccessFromWebToFollowingAuthenticatedUsers
@DefaultFile @SkipDNSLookupFor
@SkipHosts @SkipUserAgents @SkipFiles @SkipReferrers @NotPageFiles
@OnlyHosts @OnlyUserAgents @OnlyFiles @OnlyUsers
@URLWithQueryWithOnly @URLWithQueryWithout
@ExtraName @ExtraCondition @ExtraStatTypes @MaxNbOfExtra @MinHitExtra
@ExtraFirstColumnTitle @ExtraFirstColumnValues @ExtraFirstColumnFunction @ExtraFirstColumnFormat
@ExtraCodeFilter @ExtraConditionType @ExtraConditionTypeVal
@ExtraFirstColumnValuesType @ExtraFirstColumnValuesTypeVal
@ExtraAddAverageRow @ExtraAddSumRow
@PluginsToLoad
/;
@MiscListOrder=('AddToFavourites','JavascriptDisabled','Java Enabled','DirectorSupport','FlashSupport','RealPlayerSupport ','QuickTimeSupport','WindowsMediaPlayerSupport','PDFSupport ');
%MiscListCalc=('TotalMisc'=>'','AddToFavourites'=>'u','JavascriptDisabled'= >'hm','JavaEnabled'=>'hm','DirectorSupport'=>'hm','FlashSupport'= >'hm','RealPlayerSupport'=>'hm','QuickTimeSupport'=>'hm','WindowsMediaPlayerSupport'= >'hm','PDFSupport'=>'hm');
%OSFamily=('win'=>'Windows','mac'=>'Macintosh','linux'=>'Linux','bsd'= >'BSD');
%BrowsersFamily=('msie'=>1,'firefox'=>2,'netscape'=>3,'svn'= >4);
@SessionsRange=('0s-30s','30s-2mn','2mn-5mn','5mn-15mn','15m n-30mn','30mn-1h','1h+');
%SessionsAverage=('0s-30s',15,'30s-2mn',75,'2mn-5mn',210,'5m n-15mn',600,'15mn-30mn',1350,'30mn-1h',2700,'1h+',3600);
# HTTP-Accept or Lang parameter => AWStats code to use for lang
# ISO-639-1 or 2 or other => awstats-xx.txt where xx is ISO-639-1
%LangBrowserToLangAwstats=(
'sq'=>'al','ar'=>'ar','ba'=>'ba','bg'=>'bg','zh-tw'=>'tw','zh'= >'cn','cs'=>'cz',
'de'=>'de','da'=>'dk',
'en'=>'en','et'=>'et','fi'=>'fi','fr'=>'fr','gl'=>'gl',
'es'=>'es','eu'=>'eu','ca'=>'ca',
'el'=>'gr','hu'=>'hu','is'=>'is','in'=>'id','it'=>'it',
'ja'=>'jp','kr'=>'ko','lv'=>'lv','nl'=>'nl','no'=>'nb','nb'= >'nb','nn'=>'nn',
'pl'=>'pl','pt'=>'pt','pt-br'=>'br','ro'=>'ro','ru'=>'ru','sr'= >'sr','sk'=>'sk',
'sv'=>'se','th'=>'th','tr'=>'tr','uk'=>'ua','cy'=>'cy','wlk'= >'cy'
);
%LangAWStatsToFlagAwstats=( # If flag (country ISO-3166 two letters) is not same than AWStats Lang code
'ca'=>'es_cat','et'=>'ee','eu'=>'es_eu',
'cy'=>'wlk',
'gl'=>'glg',
'he'=>'il',
'ko'=>'kr',
'ar'=>'sa',
'sr'=>'cs'
);
@HostAliases = @AllowAccessFromWebToFollowingAuthenticatedUsers=();
@DefaultFile = @SkipDNSLookupFor = ();
@SkipHosts = @SkipUserAgents = @NotPageFiles = @SkipFiles = @SkipReferrers = ();
@OnlyHosts = @OnlyUserAgents = @OnlyFiles = @OnlyUsers = ();
@URLWithQueryWithOnly = @URLWithQueryWithout = ();
@ExtraName = @ExtraCondition = @ExtraStatTypes = @MaxNbOfExtra = @MinHitExtra = ();
@ExtraFirstColumnTitle = @ExtraFirstColumnValues = @ExtraFirstColumnFunction = @ExtraFirstColumnFormat = ();
@ExtraCodeFilter = @ExtraConditionType = @ExtraConditionTypeVal = ();
@ExtraFirstColumnValuesType = @ExtraFirstColumnValuesTypeVal = ();
@ExtraAddAverageRow = @ExtraAddSumRow = ();
@PluginsToLoad = ();
# ---------- Init hash arrays --------
use vars qw/
%BrowsersHashIDLib %BrowsersHashIcon %BrowsersHereAreGrabbers
%DomainsHashIDLib
%MimeHashLib %MimeHashIcon %MimeHashFamily
%OSHashID %OSHashLib
%RobotsHashIDLib %RobotsAffiliateLib
%SearchEnginesHashID %SearchEnginesHashLib %SearchEnginesWithKeysNotInQuery %SearchEnginesKnownUrl %NotSearchEnginesKeys
%WormsHashID %WormsHashLib %WormsHashTarget
/;
use vars qw/
%HTMLOutput %NoLoadPlugin %FilterIn %FilterEx
%BadFormatWarning
%MonthNumLib
%ValidHTTPCodes %ValidSMTPCodes
%TrapInfosForHTTPErrorCodes %NotPageList %DayBytes %DayHits %DayPages %DayVisits
%MaxNbOf %MinHit
%ListOfYears %HistoryAlreadyFlushed %PosInFile %ValueInFile
%val %nextval %egal
%TmpDNSLookup %TmpOS %TmpRefererServer %TmpRobot %TmpBrowser %MyDNSTable
/;
%HTMLOutput = %NoLoadPlugin = %FilterIn = %FilterEx = ();
%BadFormatWarning = ();
%MonthNumLib = ();
%ValidHTTPCodes = %ValidSMTPCodes = ();
%TrapInfosForHTTPErrorCodes=(); $TrapInfosForHTTPErrorCodes{404}=1; # TODO Add this in config file
%NotPageList=();
%DayBytes = %DayHits = %DayPages = %DayVisits = ();
%MaxNbOf = %MinHit = ();
%ListOfYears = %HistoryAlreadyFlushed = %PosInFile = %ValueInFile = ();
%val = %nextval = %egal = ();
%TmpDNSLookup = %TmpOS = %TmpRefererServer = %TmpRobot = %TmpBrowser = %MyDNSTable = ();
use vars qw/
%FirstTime %LastTime
%MonthHostsKnown %MonthHostsUnknown
%MonthUnique %MonthVisits
%MonthPages %MonthHits %MonthBytes
%MonthNotViewedPages %MonthNotViewedHits %MonthNotViewedBytes
%_session %_browser_h
%_domener_p %_domener_h %_domener_k %_errors_h %_errors_k
%_filetypes_h %_filetypes_k %_filetypes_gz_in %_filetypes_gz_out
%_host_p %_host_h %_host_k %_host_l %_host_s %_host_u
%_waithost_e %_waithost_l %_waithost_s %_waithost_u
%_keyphrases %_keywords %_os_h %_pagesrefs_p %_pagesrefs_h %_robot_h %_robot_k %_robot_l %_robot_r
%_worm_h %_worm_k %_worm_l %_login_h %_login_p %_login_k %_login_l %_screensize_h
%_misc_p %_misc_h %_misc_k
%_cluster_p %_cluster_h %_cluster_k
%_se_referrals_p %_se_referrals_h %_sider404_h %_referer404_h %_url_p %_url_k %_url_e %_url_x
%_unknownreferer_l %_unknownrefererbrowser_l
%_emails_h %_emails_k %_emails_l %_emailr_h %_emailr_k %_emailr_l
/;
&Init_HashArray();
# ---------- Init Regex --------
use vars qw/ $regclean1 $regclean2 $regdate /;
$regclean1=qr/<(recnb|\/td)>/i;
$regclean2=qr/<\/?[^<>]+>/i;
$regdate=qr/(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/;

# ---------- Init Tie::hash arrays --------
# Didn't find a tie that increase speed
#use Tie::StdHash;
#use Tie::Cache::LRU;
#tie %_host_p, 'Tie::StdHash';
#tie %TmpOS, 'Tie::Cache::LRU';

# PROTOCOL CODES
use vars qw/ %httpcodelib %ftpcodelib %smtpcodelib /;

# DEFAULT MESSAGE
use vars qw/ @Message /;
@Message=(
'Unknown',
'Unknown (unresolved ip)',
'Others',
'View details',
'Day',
'Month',
'Year',
'Statistics for',
'First visit',
'Last visit',
'Number of visits',
'Unique visitors',
'Visit',
'different keywords',
'Search',
'Percent',
'Traffic',
'Domains/Countries',
'Visitors',
'Pages-URL',
'Hours',
'Browsers',
'',
'Referers',
'Never updated (See \'Build/Update\' on awstats_setup.html page)',
'Visitors domains/countries',
'hosts',
'pages',
'different pages-url',
'Viewed',
'Other words',
'Pages not found',
'HTTP Error codes',
'Netscape versions',
'IE versions',
'Last Update',
'Connect to site from',
'Origin',
'Direct address / Bookmarks',
'Origin unknown',
'Links from an Internet Search Engine',
'Links from an external page (other web sites except search engines)',
'Links from an internal page (other page on same site)',
'Keyphrases used on search engines',
'Keywords used on search engines',
'Unresolved IP Address',
'Unknown OS (Referer field)',
'Required but not found URLs (HTTP code 404)',
'IP Address',
'Error&nbsp;Hits',
'Unknown browsers (Referer field)',
'different robots',
'visits/visitor',
'Robots/Spiders visitors',
'Free realtime logfile analyzer for advanced web statistics',
'of',
'Pages',
'Hits',
'Versions',
'Operating Systems',
'Jan',
'Feb',
'Mar',
'Apr',
'May',
'Jun',
'Jul',
'Aug',
'Sep',
'Oct',
'Nov',
'Dec',
'Navigation',
'File type',
'Update now',
'Bandwidth',
'Back to main page',
'Top',
'dd mmm yyyy - HH:MM',
'Filter',
'Full list',
'Hosts',
'Known',
'Robots',
'Sun',
'Mon',
'Tue',
'Wed',
'Thu',
'Fri',
'Sat',
'Days of week',
'Who',
'When',
'Authenticated users',
'Min',
'Average',
'Max',
'Web compression',
'Bandwidth saved',
'Compression on',
'Compression result',
'Total',
'different keyphrases',
'Entry',
'Code',
'Average size',
'Links from a NewsGroup',
'KB',
'MB',
'GB',
'Grabber',
'Yes',
'No',
'Info.',
'OK',
'Exit',
'Visits duration',
'Close window',
'Bytes',
'Search&nbsp;Keyphrases',
'Search&nbsp;Keywords',
'different refering search engines',
'different refering sites',
'Other phrases',
'Other logins (and/or anonymous users)',
'Refering search engines',
'Refering sites',
'Summary',
'Exact value not available in "Year" view',
'Data value arrays',
'Sender EMail',
'Receiver EMail',
'Reported period',
'Extra/Marketing',
'Screen sizes',
'Worm/Virus attacks',
'Add to favorites (estimated)',
'Days of month',
'Miscellaneous',
'Browsers with Java support',
'Browsers with Macromedia Director Support',
'Browsers with Flash Support',
'Browsers with Real audio playing support',
'Browsers with Quictime audio playing support',
'Browsers with Windows Media audio playing support',
'Browsers with PDF support',
'SMTP Error codes',
'Countries',
'Mails',
'Size',
'First',
'Last',
'Exclude filter',
'Codes shown here gave hits or traffic "not viewed" by visitors, so they are not included in other charts.',
'Cluster',
'Robots shown here gave hits or traffic "not viewed" by visitors, so they are not included in other charts.',
'Numbers after + are successful hits on "robots.txt" files',
'Worms shown here gave hits or traffic "not viewed" by visitors, so thay are not included in other charts.',
'Not viewed traffic includes traffic generated by robots, worms, or replies with special HTTP status codes.',
'Traffic viewed',
'Traffic not viewed',
'Monthly history',
'Worms',
'different worms',
'Mails successfully sent',
'Mails failed/refused',
'Sensitive targets',
'Javascript disabled',
'Created by',
'plugins',
'Regions',
'Cities'
);



#----------------------------------------------------------- -------------------
# Functions
#----------------------------------------------------------- -------------------

# Function to solve pb with openvms
sub file_filt (@) {
my @retval;
foreach my $fl (@_) {
$fl =~ tr/^//d;
push @retval, $fl;
}
return sort @retval;
}

#----------------------------------------------------------- -------------------
# Function: Write on output header of HTTP answer
# Parameters: None
# Input: $HeaderHTTPSent $BuildReportFormat $PageCode $Expires
# Output: $HeaderHTTPSent=1
# Return: None
#----------------------------------------------------------- -------------------
sub http_head {
if (! $HeaderHTTPSent) {
if ($BuildReportFormat eq 'xhtml' || $BuildReportFormat eq 'xml') { print ($ENV{'HTTP_USER_AGENT'}=~/MSIE|Googlebot/i?"Content-type: text/html; charset=$PageCode\n":"Content-type: text/xml; charset=$PageCode\n"); }
else { print "Content-type: text/html; charset=$PageCode\n"; }

# Expires must be GMT ANSI asctime and must be after Content-type to avoid pb with some servers (SAMBAR)
if ($Expires =~ /^\d+$/) {
print "Cache-Control: public\n";
print "Last-Modified: ".gmtime($starttime)."\n";
print "Expires: ".(gmtime($starttime+$Expires))."\n";
}
print "\n";
}
$HeaderHTTPSent++;
}

#----------------------------------------------------------- -------------------
# Function: Write on output header of HTML page
# Parameters: None
# Input: %HTMLOutput $PluginMode $Expires $Lang $StyleSheet $HTMLHeadSection $PageCode $PageDir
# Output: $HeaderHTMLSent=1
# Return: None
#----------------------------------------------------------- -------------------
sub html_head {
my $dir=$PageDir?'right':'left';
if (scalar keys %HTMLOutput || $PluginMode) {
my $periodtitle=" ($YearRequired";
$periodtitle.=($MonthRequired ne 'all'?"-$MonthRequired":"");
$periodtitle.=($DayRequired ne ''?"-$DayRequired":"");
$periodtitle.=($HourRequired ne ''?"-$HourRequired":"");
$periodtitle.=")";
# Write head section
if ($BuildReportFormat eq 'xhtml' || $BuildReportFormat eq 'xml') {
if ($PageCode) { print "<?xml version=\"1.0\" encoding=\"$PageCode\"?>\n"; }
else { print "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"; };
if ($FrameName ne 'index') { print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"; }
else { print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\n"; }
print "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"$Lang\">\n";
} else {
if ($FrameName ne 'index') { print "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"; }
else { print "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\">\n"; }
print "<html lang='$Lang'".($PageDir?" dir='rtl'":"").">\n";
}
print "<head>\n";

my $endtag='>';
if ($BuildReportFormat eq 'xhtml' || $BuildReportFormat eq 'xml') { $endtag=' />'; }

# Affiche tag meta generator
print "<meta name=\"generator\" content=\"AWStats $VERSION from config file awstats.$SiteConfig.conf (http://awstats.sourceforge.net)\"$endtag\n";

# Affiche tag meta robots
if ($MetaRobot) { print "<meta name=\"robots\" content=\"".($FrameName eq 'mainleft'?'no':'')."index,".($FrameName eq 'mainleft' || $FrameName eq 'index'?'':'no')."follow\"$endtag\n"; }
else { print "<meta name=\"robots\" content=\"noindex,nofollow\"$endtag\n"; }

# Affiche tag meta content-type
if ($BuildReportFormat eq 'xhtml' || $BuildReportFormat eq 'xml') { print ($ENV{'HTTP_USER_AGENT'}=~/MSIE|Googlebot/i?"<meta http-equiv=\"content-type\" content=\"text/html; charset=".($PageCode?$PageCode:"iso-8859-1")."\" />\n":"<meta http-equiv=\"content-type\" content=\"text/xml; charset=".($PageCode?$PageCode:"iso-8859-1")."\"$endtag\n "); }
else { print "<meta http-equiv=\"content-type\" content=\"text/html; charset=".($PageCode?$PageCode:"iso-8859-1")."\"$endtag\n "; }

if ($Expires) { print "<meta http-equiv=\"expires\" content=\"".(gmtime($starttime+$Expires))."\"$endtag\n"; }
my @k = keys %HTMLOutput; # This is to have a unique title and description page
print "<meta http-equiv=\"description\" content=\"".ucfirst($PROG)." - Advanced Web Statistics for $SiteDomain$periodtitle".($k[0]?" - ".$k[0]:"")."\"$endtag\n";
if ($MetaRobot && $FrameName ne 'mainleft') { print "<meta http-equiv=\"keywords\" content=\"$SiteDomain, free, advanced, realtime, web, server, logfile, log, analyzer, analysis, statistics, stats, perl, analyse, performance, hits, visits\"$endtag\n"; }
print "<title>$Message[7] $SiteDomain$periodtitle".($k[0]?" - ".$k[0]:"")."</title>\n";
if ($FrameName ne 'index')
{

if ($StyleSheet) {
print "<link rel=\"stylesheet\" href=\"$StyleSheet\" />\n";
}

# A STYLE section must be in head section. Do not use " for number in a style section
print "<style type=\"text/css\">\n";
if ($BuildReportFormat eq 'xhtml' || $BuildReportFormat eq 'xml') { print ($ENV{'HTTP_USER_AGENT'}=~/Firebird/i?"<!--\n":"<![CDATA[\n "); }
else { print "<!--\n"; }

if (! $StyleSheet)
{
print "body { font: 11px verdana, arial, helvetica, sans-serif; background-color: #$color_Background; margin-top: 0; margin-bottom: 0; }\n";
print ".aws_bodyl { }\n";
print ".aws_border { border-collapse: collapse; background-color: #$color_TableBG; padding: 1px 1px ".($BuildReportFormat eq 'xhtml' || $BuildReportFormat eq 'xml'?"2px":"1px")." 1px; margin-top: 0px; margin-bottom: 0px; }\n";
print ".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";
print ".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";
print <<EOF;
..aws_data {
background-color: #$color_Background;
border-top-width: 1px;
border-left-width: 0px;
border-right-width: 0px;
border-bottom-width: 0px;
}
..aws_formfield { font: 13px verdana, arial, helvetica; }
..aws_button {
font-family: arial,verdana,helvetica, sans-serif;
font-size: 12px;
border: 1px solid #ccd7e0;
background-image : url($DirIcons/other/button.gif);
}
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; }
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; }
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; }
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;}
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; }
b { font-weight: bold; }
a { font: 11px verdana, arial, helvetica, sans-serif; }
a:link { color: #$color_link; text-decoration: none; }
a:visited { color: #$color_link; text-decoration: none; }
a:hover { color: #$color_hover; text-decoration: underline; }
..currentday { font-weight: bold; }
EOF
}

# Call to plugins' function AddHTMLStyles
foreach my $pluginname (keys %{$PluginsLoaded{'AddHTMLStyles'}}) {
# my $function="AddHTMLStyles_$pluginname()";
# eval("$function");
my $function="AddHTMLStyles_$pluginname";
&$function();
}

if ($BuildReportFormat eq 'xhtml' || $BuildReportFormat eq 'xml') { print ($ENV{'HTTP_USER_AGENT'}=~/Firebird/i?"//-->\n":"]]>\n"); }
else { print "//-->\n"; }
print "</style>\n";
}

print "</head>\n\n";
if ($FrameName ne 'index') {
print "<body style=\"margin-top: 0px\"";
if ($FrameName eq 'mainleft') { print " class=\"aws_bodyl\""; }
print ">\n";
}
}
$HeaderHTMLSent++;
}

#----------------------------------------------------------- -------------------
# Function: Write on output end of HTML page
# Parameters: 0|1 (0=no list plugins,1=list plugins)
# Input: %HTMLOutput $HTMLEndSection $FrameName $BuildReportFormat
# Output: None
# Return: None
#----------------------------------------------------------- -------------------
sub html_end {
my $listplugins=shift||0;
if (scalar keys %HTMLOutput) {

# Call to plugins' function AddHTMLBodyFooter
foreach my $pluginname (keys %{$PluginsLoaded{'AddHTMLBodyFooter'}}) {
# my $function="AddHTMLBodyFooter_$pluginname()";
# eval("$function");
my $function="AddHTMLBodyFooter_$pluginname";
&$function();
}

if ($FrameName ne 'index' && $FrameName ne 'mainleft') {
print "$Center<br /><br />\n";
print "<span dir=\"ltr\" style=\"font: 11px verdana, arial, helvetica; color: #$color_text;\">";
print "<b>Advanced Web Statistics $VERSION</b> - <a href=\"http://awstats.sourceforge.net\" target=\"awstatshome\">";
print $Message[169]." $PROG";
if ($listplugins) {
my $atleastoneplugin=0;
foreach my $pluginname (keys %{$PluginsLoaded{'init'}}) {
if (! $atleastoneplugin) { $atleastoneplugin=1; print " ($Message[170]: "; }
else { print ", "; }
print "$pluginname";
}
if ($atleastoneplugin) { print ")"; }
}
print "</a></span><br />\n";
if ($HTMLEndSection) { print "<br />\n$HTMLEndSection\n"; }
}
print "\n";
if ($FrameName ne 'index') {
if ($FrameName ne 'mainleft' && $BuildReportFormat eq 'html') { print "<br />\n"; }
print "</body>\n";
}
print "</html>\n";
# print "<!-- NEW PAGE --><!-- NEW SHEET -->\n";
}
}

#----------------------------------------------------------- -------------------
# Function: Print on stdout tab header of a chart
# Parameters: $title $tooltipnb [$width percentage of chart title]
# Input: None
# Output: None
# Return: None
#----------------------------------------------------------- -------------------
sub tab_head {
my $title=shift;
my $tooltipnb=shift;
my $width=shift||70;
my $class=shift;
if ($width == 70 && $QueryString =~ /buildpdf/i) { print "<table class=\"aws_border\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\" width=\"800\">\n"; }
else { print "<table class=\"aws_border\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\" width=\"100%\">\n"; }

if ($tooltipnb) {
print "<tr><td class=\"aws_title\" width=\"$width%\"".Tooltip($tooltipnb,$tooltipnb).">$title </td>";
}
else {
print "<tr><td class=\"aws_title\" width=\"$width%\">$title </td>";
}
print "<td class=\"aws_blank\">&nbsp;</td></tr>\n";
print "<tr><td colspan=\"2\">\n";
if ($width == 70 && $QueryString =~ /buildpdf/i) { print "<table class=\"aws_data\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\" width=\"796\">\n"; }
else { print "<table class=\"aws_data\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\" width=\"100%\">\n"; }
}

#----------------------------------------------------------- -------------------
# Function: Print on stdout tab ender of a chart
# Parameters: None
# Input: None
# Output: None
# Return: None
#----------------------------------------------------------- -------------------
sub tab_end {
my $string=shift;
print "</table></td></tr></table>";
if ($string) { print "<span style=\"font: 11px verdana, arial, helvetica;\">$string</span><br />\n"; }
print "<br />\n\n";
}

#----------------------------------------------------------- -------------------
# Function: Write error message and exit
# Parameters: $message $secondmessage $thirdmessage $donotshowsetupinfo
# Input: $HeaderHTTPSent $HeaderHTMLSent %HTMLOutput $LogSeparator $LogFormat
# Output: None
# Return: None
#----------------------------------------------------------- -------------------
sub error {
my $message=shift||''; if (scalar keys %HTMLOutput) { $message =~ s/\</&lt;/g; $message =~ s/\>/&gt;/g; }
my $secondmessage=shift||'';
my $thirdmessage=shift||'';
my $donotshowsetupinfo=shift||0;

if (! $HeaderHTTPSent && $ENV{'GATEWAY_INTERFACE'}) { http_head(); }
if (! $HeaderHTMLSent && scalar keys %HTMLOutput) { print "<html><body>\n"; $HeaderHTMLSent=1; }
if ($Debug) { debug("$message $secondmessage $thirdmessage",1); }
my $tagbold=''; my $tagunbold=''; my $tagbr=''; my $tagfontred=''; my $tagfontgrey=''; my $tagunfont='';
if (scalar keys %HTMLOutput) {
$tagbold='<b>'; $tagunbold='</b>'; $tagbr='<br />';
$tagfontred='<span style="color: #880000">';
$tagfontgrey='<span style="color: #888888">';
$tagunfont='</span>';
}
if (! $ErrorMessages && $message =~ /^Format error$/i) {
# Files seems to have bad format
if (scalar keys %HTMLOutput) { print "<br /><br />\n"; }
if ($message !~ $LogSeparator) {
# Bad LogSeparator parameter
print "${tagfontred}AWStats did not found the ${tagbold}LogSeparator${tagunbold} in your log records.${tagbr}${tagunfont}\n";
}
else {
# Bad LogFormat parameter
print "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";
print "${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";
print "Your AWStats ${tagbold}LogFormat${tagunbold} parameter is:\n";
print "${tagbold}$LogFormat${tagunbold}${tagbr}\n";
print "This means each line in your web server log file need to have ";
if ($LogFormat == 1) {
print "${tagbold}\"combined log format\"${tagunbold} like this:${tagbr}\n";
print (scalar keys %HTMLOutput?"$tagfontgrey<i>":"");
print "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";
print (scalar keys %HTMLOutput?"</i>$tagunfont${tagbr}${tagbr}\n":"");
}
if ($LogFormat == 2) {
print "${tagbold}\"MSIE Extended W3C log format\"${tagunbold} like this:${tagbr}\n";
print (scalar keys %HTMLOutput?"$tagfontgrey<i>":"");
print "date time c-ip c-username cs-method cs-uri-sterm sc-status sc-bytes cs-version cs(User-Agent) cs(Referer)\n";
print (scalar keys %HTMLOutput?"</i>$tagunfont${tagbr}${tagbr}\n":"");
}
if ($LogFormat == 3) {
print "${tagbold}\"WebStar native log format\"${tagunbold}${tagbr}\n";
}
if ($LogFormat == 4) {
print "${tagbold}\"common log format\"${tagunbold} like this:${tagbr}\n";
print (scalar keys %HTMLOutput?"$tagfontgrey<i>":"");
print "111.22.33.44 - - [10/Jan/2001:02:14:14 +0200] \"GET / HTTP/1.1\" 200 1234\n";
print (scalar keys %HTMLOutput?"</i>$tagunfont${tagbr}${tagbr}\n":"");
}
if ($LogFormat == 6) {
print "${tagbold}\"Lotus Notes/Lotus Domino\"${tagunbold}${tagbr}\n";
print (scalar keys %HTMLOutput?"$tagfontgrey<i>":"");
print "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";
print (scalar keys %HTMLOutput?"</i></span>${tagbr}${tagbr}\n":"");
}
if ($LogFormat !~ /^[1-6]$/) {
print "the following personalized log format:${tagbr}\n";
print (scalar keys %HTMLOutput?"$tagfontgrey<i>":"");
print "$LogFormat\n";
print (scalar keys %HTMLOutput?"</i>$tagunfont${tagbr}${tagbr}\n":"");
}
print "And this is an example of records AWStats found in your log file (the record number $NbOfLinesForCorruptedLog in your log):\n";
print (scalar keys %HTMLOutput?"<br />$tagfontgrey<i>":"");
print "$secondmessage";
print (scalar keys %HTMLOutput?"</i>$tagunfont${tagbr}${tagbr}":"");
print "\n";
}
#print "Note: If your $NbOfLinesForCorruptedLog first lines in your log files are wrong because of ";
#print "a worm virus attack, you can increase the NbOfLinesForCorruptedLog parameter in config file.\n";
#print "\n";
}
else {
print (scalar keys %HTMLOutput?"<br />$tagfontred\n":"");
print ($ErrorMessages?"$ErrorMessages":"Error: $message");
print (scalar keys %HTMLOutput?"\n</span><br />":"");
print "\n";
}
if (! $ErrorMessages && ! $donotshowsetupinfo) {
if ($message =~ /Couldn.t open config file/i) {
my $dir=$DIR;
if ($dir =~ /^\./) { $dir.='/../..'; }
else { $dir =~ s/[\\\/]?wwwroot[\/\\]cgi-bin[\\\/]?//; }
print "${tagbr}\n";
if ($ENV{'GATEWAY_INTERFACE'}) {
print "- ${tagbold}Did you use the correct URL ?${tagunbold}${tagbr}\n";
print "Example: http://localhost/awstats/awstats.pl?config=mysite${tagbr}\n";
print "Example: http://127.0.0.1/cgi-bin/awstats.pl?config=mysite${tagbr}\n";
} else {
print "- ${tagbold}Did you use correct config parameter ?${tagunbold}${tagbr}\n";
print "Example: If your config file is awstats.mysite.conf, use -config=mysite\n";
}
print "- ${tagbold}Did you create your config file 'awstats.$SiteConfig.conf' ?${tagunbold}${tagbr}\n";
print "If not, you can run \"awstats_configure.pl\"\nfrom command line, or create it manually.${tagbr}\n";
print "${tagbr}\n";
}
else { print "${tagbr}${tagbold}Setup (".($FileConfig?"'".$FileConfig."'":"Config")." file, web server or permissions) may be wrong.${tagunbold}${tagbr}\n"; }
print "Check config file, permissions and AWStats documentation (in 'docs' directory).\n";
}
# Remove lock if not a lock message
if ($EnableLockForUpdate && $message !~ /lock file/) { &Lock_Update(0); }
if (scalar keys %HTMLOutput) { print "</body></html>\n"; }
exit 1;
}

#----------------------------------------------------------- -------------------
# Function: Write a warning message
# Parameters: $message
# Input: $HeaderHTTPSent $HeaderHTMLSent $WarningMessage %HTMLOutput
# Output: None
# Return: None
#----------------------------------------------------------- -------------------
sub warning {
my $messagestring=shift;

if ($Debug) { debug("$messagestring",1); }
if ($WarningMessages) {
if (! $HeaderHTTPSent && $ENV{'GATEWAY_INTERFACE'}) { http_head(); }
if (! $HeaderHTMLSent) { html_head(); }
if (scalar keys %HTMLOutput) {
$messagestring =~ s/\n/\<br\>/g;
print "$messagestring<br />\n";
}
else {
print "$messagestring\n";
}
}
}

#----------------------------------------------------------- -------------------
# Function: Write debug message and exit
# Parameters: $string $level
# Input: %HTMLOutput $Debug=required level $DEBUGFORCED=required level forced
# Output: None
# Return: None
#----------------------------------------------------------- -------------------
sub debug {
my $level = $_[1] || 1;

if (! $HeaderHTTPSent && $ENV{'GATEWAY_INTERFACE'}) { http_head(); } # To send the HTTP header and see debug
if ($level <= $DEBUGFORCED) {
my $debugstring = $_[0];
if (! $DebugResetDone) { open(DEBUGFORCEDFILE,"debug.log"); close DEBUGFORCEDFILE; chmod 0666,"debug.log"; $DebugResetDone=1; }
open(DEBUGFORCEDFILE,">>debug.log");
print DEBUGFORCEDFILE localtime(time)." - $$ - DEBUG $level - $debugstring\n";
close DEBUGFORCEDFILE;
}
if ($DebugMessages && $level <= $Debug) {
my $debugstring = $_[0];
if (scalar keys %HTMLOutput) { $debugstring =~ s/^ /&nbsp;&nbsp; /; $debugstring .= "<br />"; }
print localtime(time)." - DEBUG $level - $debugstring\n";
}
}

#----------------------------------------------------------- -------------------
# Function: Optimize an array removing duplicate entries
# Parameters: @Array notcasesensitive=0|1
# Input: None
# Output: None
# Return: None
#----------------------------------------------------------- -------------------
sub OptimizeArray {
my $array=shift;
my @arrayunreg=map{if (/\(\?[-\w]*:(.*)\)/) { $1 } } @$array;
my $notcasesensitive=shift;
my $searchlist=0;
if ($Debug) { debug("OptimizeArray (notcasesensitive=$notcasesensitive)",4); }
while ($searchlist>-1 && @arrayunreg) {
my $elemtoremove=-1;
OPTIMIZELOOP:
foreach my $i ($searchlist..(scalar @arrayunreg)-1) {
# Search if $i elem is already treated by another elem
foreach my $j (0..(scalar @arrayunreg)-1) {
if ($i == $j) { next; }
my $parami=$notcasesensitive?lc($arrayunreg[$i]):$arrayunreg[$i ];
my $paramj=$notcasesensitive?lc($arrayunreg[$j]):$arrayunreg[$j ];
if ($Debug) { debug(" Compare $i ($parami) to $j ($paramj)",4); }
if (index($parami,$paramj)>-1) {
if ($Debug) { debug(" Elem $i ($arrayunreg[$i]) already treated with elem $j ($arrayunreg[$j])",4); }
$elemtoremove=$i;
last OPTIMIZELOOP;
}
}
}
if ($elemtoremove > -1) {
if ($Debug) { debug(" Remove elem $elemtoremove - $arrayunreg[$elemtoremove]",4); }
splice @arrayunreg, $elemtoremove, 1;
$searchlist=$elemtoremove;
}
else {
$searchlist=-1;
}
}
if ($notcasesensitive) { return map{qr/$_/i} @arrayunreg; }
return map{qr/$_/} @arrayunreg;
}

#----------------------------------------------------------- -------------------
# Function: Check if parameter is in SkipDNSLookupFor array
# Parameters: ip @SkipDNSLookupFor (a NOT case sensitive precompiled regex array)
# Return: 0 Not found, 1 Found
#----------------------------------------------------------- -------------------
sub SkipDNSLookup {
foreach (@SkipDNSLookupFor) { if ($_[0] =~ /$_/) { return 1; } }
0; # Not in @SkipDNSLookupFor
}

#----------------------------------------------------------- -------------------
# Function: Check if parameter is in SkipHosts array
# Parameters: host @SkipHosts (a NOT case sensitive precompiled regex array)
# Return: 0 Not found, 1 Found
#----------------------------------------------------------- -------------------
sub SkipHost {
foreach (@SkipHosts) { if ($_[0] =~ /$_/) { return 1; } }
0; # Not in @SkipHosts
}

#----------------------------------------------------------- -------------------
# Function: Check if parameter is in SkipReferrers array
# Parameters: host @SkipReferrers (a NOT case sensitive precompiled regex array)
# Return: 0 Not found, 1 Found
#----------------------------------------------------------- -------------------
sub SkipReferrer {
foreach (@SkipReferrers) { if ($_[0] =~ /$_/) { return 1; } }
0; # Not in @SkipReferrers
}

#----------------------------------------------------------- -------------------
# Function: Check if parameter is in SkipUserAgents array
# Parameters: useragent @SkipUserAgents (a NOT case sensitive precompiled regex array)
# Return: 0 Not found, 1 Found
#----------------------------------------------------------- -------------------
sub SkipUserAgent {
foreach (@SkipUserAgents) { if ($_[0] =~ /$_/) { return 1; } }
0; # Not in @SkipUserAgent
}

#----------------------------------------------------------- -------------------
# Function: Check if parameter is in SkipFiles array
# Parameters: url @SkipFiles (a NOT case sensitive precompiled regex array)
# Return: 0 Not found, 1 Found
#----------------------------------------------------------- -------------------
sub SkipFile {
foreach (@SkipFiles) { if ($_[0] =~ /$_/) { return 1; } }
0; # Not in @SkipFiles
}

#----------------------------------------------------------- -------------------
# Function: Check if parameter is in OnlyHosts array
# Parameters: host @OnlyHosts (a NOT case sensitive precompiled regex array)
# Return: 0 Not found, 1 Found
#----------------------------------------------------------- -------------------
sub OnlyHost {
foreach (@OnlyHosts) { if ($_[0] =~ /$_/) { return 1; } }
0; # Not in @OnlyHosts
}

#----------------------------------------------------------- -------------------
# Function: Check if parameter is in OnlyUsers array
# Parameters: host @OnlyUsers (a NOT case sensitive precompiled regex array)
# Return: 0 Not found, 1 Found
#----------------------------------------------------------- -------------------
sub OnlyUser{
foreach (@OnlyUsers) { if ($_[0] =~ /$_/) { return 1; } }
0; # Not in @OnlyUsers
}

#----------------------------------------------------------- -------------------
# Function: Check if parameter is in OnlyUserAgents array
# Parameters: useragent @OnlyUserAgents (a NOT case sensitive precompiled regex array)
# Return: 0 Not found, 1 Found
#----------------------------------------------------------- -------------------
sub OnlyUserAgent {
foreach (@OnlyUserAgents) { if ($_[0] =~ /$_/) { return 1; } }
0; # Not in @OnlyUserAgents
}

#----------------------------------------------------------- -------------------
# Function: Check if parameter is in NotPageFiles array
# Parameters: url @NotPageFiles (a NOT case sensitive precompiled regex array)
# Return: 0 Not found, 1 Found
#----------------------------------------------------------- -------------------
sub NotPageFile {
foreach (@NotPageFiles) { if ($_[0] =~ /$_/) { return 1; } }
0; # Not in @NotPageFiles
}

#----------------------------------------------------------- -------------------
# Function: Check if parameter is in OnlyFiles array
# Parameters: url @OnlyFiles (a NOT case sensitive precompiled regex array)
# Return: 0 Not found, 1 Found
#----------------------------------------------------------- -------------------
sub OnlyFile {
foreach (@OnlyFiles) { if ($_[0] =~ /$_/) { return 1; } }
0; # Not in @OnlyFiles
}

#----------------------------------------------------------- -------------------
# Function: Return day of week of a day
# Parameters: $day $month $year
# Return: 0-6
#----------------------------------------------------------- -------------------
sub DayOfWeek {
my ($day, $month, $year) = @_;
if ($Debug) { debug("DayOfWeek for $day $month $year",4); }
if ($month < 3) { $month += 10; $year--; }
else { $month -= 2; }
my $cent = sprintf("%1i",($year/100));
my $y = ($year % 100);
my $dw = (sprintf("%1i",(2.6*$month)-0.2) + $day + $y + sprintf("%1i",($y/4)) + sprintf("%1i",($cent/4)) - (2*$cent)) % 7;
$dw += 7 if ($dw<0);
if ($Debug) { debug(" is $dw",4); }
return $dw;
}

#----------------------------------------------------------- -------------------
# Function: Return 1 if a date exists
# Parameters: $day $month $year
# Return: 1 if date exists else 0
#----------------------------------------------------------- -------------------
sub DateIsValid {
my ($day, $month, $year) = @_;
if ($Debug) { debug("DateIsValid for $day $month $year",4); }
if ($day < 1) { return 0; }
if ($day > 31) { return 0; }
if ($month==4 || $month==6 || $month==9 || $month==11) {
if ($day > 30) { return 0; }
}
elsif ($month==2) {
my $leapyear=($year%4==0?1:0); # A leap year every 4 years
if ($year%100==0 && $year%400!=0) { $leapyear=0; } # Except if year is 100x and not 400x
if ($day > (28+$leapyear)) { return 0; }
}
return 1;
}

#----------------------------------------------------------- -------------------
# Function: Return string of visit duration
# Parameters: $starttime $endtime
# Input: None
# Output: None
# Return: A string that identify the visit duration range
#----------------------------------------------------------- -------------------
sub GetSessionRange {
my $starttime = my $endtime;
if (shift =~ /$regdate/o) { $starttime = Time::Local::timelocal($6,$5,$4,$3,$2-1,$1); }
if (shift =~ /$regdate/o) { $endtime = Time::Local::timelocal($6,$5,$4,$3,$2-1,$1); }
my $delay=$endtime-$starttime;
if ($Debug) { debug("GetSessionRange $endtime - $starttime = $delay",4); }
if ($delay <= 30) { return $SessionsRange[0]; }
if ($delay <= 120) { return $SessionsRange[1]; }
if ($delay <= 300) { return $SessionsRange[2]; }
if ($delay <= 900) { return $SessionsRange[3]; }
if ($delay <= 1800) { return $SessionsRange[4]; }
if ($delay <= 3600) { return $SessionsRange[5]; }
return $SessionsRange[6];
}

#----------------------------------------------------------- -------------------
# Function: Read config file
# Parameters: None or configdir to scan
# Input: $DIR $PROG $SiteConfig
# Output: Global variables
# Return: -
#----------------------------------------------------------- -------------------
sub Read_Config {
# Check config file in common possible directories :
# Windows : "$DIR" (same dir than awstats.pl)
# Standard, Mandrake and Debian package : "/etc/awstats"
# Other possible directories : "/usr/local/etc/awstats", "/etc"
# FHS standard, Suse package : "/etc/opt/awstats"
my $configdir=shift;
my @PossibleConfigDir=();

if ($configdir)
{
# If from CGI, overwriting of configdir is only possible if AWSTATS_ENABLE_CONFIG_DIR defined
#if ($ENV{'GATEWAY_INTERFACE'} && ! $ENV{"AWSTATS_ENABLE_CONFIG_DIR"})
#{
# error("Sorry, to allow overwriting of configdir parameter from an AWStats CGI usage, environment variable AWSTATS_ENABLE_CONFIG_DIR must be set to 1");
#}
#else
#{
@PossibleConfigDir=("$configdir");
#}
}
else { @PossibleConfigDir=("$DIR","/etc/awstats","/usr/local/etc/awstats ","/etc","/etc/opt/awstats"); }

# Open config file
$FileConfig=$FileSuffix='';
foreach (@PossibleConfigDir) {
my $searchdir=$_;
if ($searchdir && $searchdir !~ /[\\\/]$/) { $searchdir .= "/"; }
if (open(CONFIG,"$searchdir$PROG.$SiteConfig.conf")) { $FileConfig="$searchdir$PROG.$SiteConfig.conf"
Previous Topic:Build path entry is missing
Next Topic:PDT 2.0 most important bugs
Goto Forum:
  


Current Time: Fri Apr 26 09:51:39 GMT 2024

Powered by FUDForum. Page generated in 0.03176 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top