)
{
chomp $_; s/\r//;
- if (/^$/) { next; } # Ignore blank lines (With ISS: happens sometimes, with Apache: possible when editing log file)
if (/^#/) { next; } # Ignore comment lines (ISS writes such comments)
if (/^!!/) { next; } # Ignore comment lines (Webstar writes such comments)
- $NbOfLinesProcessed++;
+ if (/^$/) { next; } # Ignore blank lines (With ISS: happens sometimes, with Apache: possible when editing log file)
+
+ $NbOfLinesRead++;
# Parse line record to get all required fields
$_ =~ /^$PerlParsingFormat/;
foreach $i (1..$lastrequiredfield) { $field[$i]=$$i; }
- &debug("Fields for record $NbOfLinesProcessed: $field[$pos_rc] ; - ; - ; $field[$pos_date] ; TZ; $field[$pos_method] ; $field[$pos_url] ; $field[$pos_code] ; $field[$pos_size] ; $field[$pos_referer] ; $field[$pos_agent]",3);
+ &debug(" Record $NbOfLinesRead is: $field[$pos_rc] ; - ; - ; $field[$pos_date] ; TZ; $field[$pos_method] ; $field[$pos_url] ; $field[$pos_code] ; $field[$pos_size] ; $field[$pos_referer] ; $field[$pos_agent]",3);
# Check parsed parameters
#----------------------------------------------------------------------
if ($field[$pos_code] eq "") {
$NbOfLinesCorrupted++;
- if ($NbOfLinesProcessed >= 10 && $NbOfLinesCorrupted == $NbOfLinesProcessed) {
- # Files seems to have bad format
- print "AWStats did not found any valid log lines that match your LogFormat parameter, in the 10th first non commented lines of your log.
\n";
- print "Your log file $LogFile must have a bad format or LogFormat parameter setup is wrong.
\n";
- print "Your LogFormat parameter is $LogFormat, this means each line in your log file need to have ";
- if ($LogFormat == 1) {
- print "\"combined log format\" like this:
\n";
- 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";
- }
- if ($LogFormat == 2) {
- print "\"MSIE Extended W3C log format\" like this:
\n";
- print "date time c-ip c-username cs-method cs-uri-sterm sc-status sc-bytes cs-version cs(User-Agent) cs(Referer)
\n";
- }
- if ($LogFormat != 1 && $LogFormat != 2) {
- print "the following personalised log format:
\n";
- print "$LogFormat
\n";
- }
- print "
";
- print "And this is a sample of what AWStats found in your log (the 10th non commented line):
\n";
- print "$_
\n";
-
- error(""); # Exit with format error
- }
+ if ($NbOfLinesRead >= 10 && $NbOfLinesCorrupted == $NbOfLinesRead) { error("Format error",$_,$LogFile); } # Exit with format error
next;
}
@@ -1831,14 +1901,22 @@ if ($UpdateStats) {
if ($timeconnexion < $LastTime{$yeartoprocess.$monthtoprocess}) { next; } # Should not happen, kept in case of parasite/corrupted old line
}
else {
- if ($timeconnexion <= $LastTime{$yeartoprocess.$monthtoprocess}) { next; } # Already processed
+ if ($timeconnexion <= $LastTime{$yeartoprocess.$monthtoprocess}) {
+ # NEXT LINE IS FOR TEST
+ if (($QueryString =~ /showstep=1/i) && ($NbOfLinesRead % 4000 == 0)) { print "$NbOfLinesRead lines read already processed (".(time()-$starttime)." seconds, ".($NbOfLinesRead/(time()-$starttime+1))." lines/seconds)\n"; }
+ next;
+ } # Already processed
$NowNewLinePhase=1; # This will stop comparison "<=" between timeconnexion and LastTime (we should have only new lines now)
}
+ # Here, field array, datepart array, timeconnexion and dayconnexion are init for log record
+ &debug(" This is a not already processed record",3);
+
# Record is approved. We found a new line
#----------------------------------------
$NbOfNewLinesProcessed++;
- #if (($QueryString =~ /showstep=1/i) && ($NbOfNewLinesProcessed % 1000 == 0)) { print "$NbOfNewLinesProcessed lines processed\n"; }
+ # NEXT LINE IS FOR TEST
+ if (($QueryString =~ /showstep=1/i) && ($NbOfNewLinesProcessed % 4000 == 0)) { print "$NbOfNewLinesProcessed lines processed (".(time()-$starttime)." seconds, ".($NbOfNewLinesProcessed/(time()-$starttime+1))." lines/seconds)\n"; }
if (&SkipHost($field[$pos_rc])) { next; } # Skip with some client host IP addresses
if (&SkipFile($field[$pos_url])) { next; } # Skip with some URLs
@@ -2146,18 +2224,18 @@ if ($UpdateStats) {
}
}
- # News link ?
+ # Origin not found
if (!$found) {
- if ($field[$pos_referer] =~ /^news/i) {
- if ($PageBool) { $_from_p[1]++; }
- $_from_h[1]++;
- $found=1;
- }
+ if ($PageBool) { $_from_p[1]++; }
+ $_from_h[1]++;
}
+ # End of processing all new records.
}
+ &debug("End of processing log file(s)");
+
+ &debug("Close log file");
close LOG;
- &debug("End of processing log file");
# DNSLookup warning
if ($DNSLookup && !$NewDNSLookup) { warning("Warning: $PROG has detected that hosts names are already resolved in your logfile $LogFile.
\nIf this is always true, you should change your setup DNSLookup=1 into DNSLookup=0 to increase $PROG speed."); }
@@ -2191,13 +2269,13 @@ if ($UpdateStats) {
close DIR;
foreach $i (0..$#filearray) {
if ("$filearray[$i]" =~ /^$PROG[\d][\d][\d][\d][\d][\d]$FileSuffix\.tmp\..*$/) {
- $yearmonthfile=$filearray[$i]; $yearmonthfile =~ s/^$PROG//; $yearmonthfile =~ s/\..*//;
- if (-s "$DirData/$PROG$yearmonthfile$FileSuffix.tmp.$$") { # Rename only files for this session and with size > 0
- if (rename("$DirData/$PROG$yearmonthfile$FileSuffix.tmp.$$", "$DirData/$PROG$yearmonthfile$FileSuffix.txt")==0) {
+ my $yearmonth=$filearray[$i]; $yearmonth =~ s/^$PROG//; $yearmonth =~ s/\..*//;
+ if (-s "$DirData/$PROG$yearmonth$FileSuffix.tmp.$$") { # Rename only files for this session and with size > 0
+ if (rename("$DirData/$PROG$yearmonth$FileSuffix.tmp.$$", "$DirData/$PROG$yearmonth$FileSuffix.txt")==0) {
$allok=0; # At least one error in renaming working files
last;
}
- chmod 0666,"$DirData/$PROG$yearmonthfile$FileSuffix.txt";
+ chmod 0666,"$DirData/$PROG$yearmonth$FileSuffix.txt";
}
}
}
@@ -2217,8 +2295,8 @@ opendir(DIR,"$DirData");
close DIR;
foreach $i (0..$#filearray) {
if ("$filearray[$i]" =~ /^$PROG[\d][\d][\d][\d][\d][\d]$FileSuffix\.txt$/) {
- $yearmonthfile=$filearray[$i]; $yearmonthfile =~ s/^$PROG//; $yearmonthfile =~ s/\..*//;
- $yearfile=$yearmonthfile; $yearfile =~ s/^..//;
+ my $yearmonth=$filearray[$i]; $yearmonth =~ s/^$PROG//; $yearmonth =~ s/\..*//;
+ my $yearfile=$yearmonth; $yearfile =~ s/^..//;
$listofyears{$yearfile}=1;
}
}
@@ -2350,6 +2428,28 @@ if ($QueryString =~ /action=browserdetail/i) {
}
&tab_end;
+ &html_end;
+ exit(0);
+ }
+if ($QueryString =~ /action=urldetail/i) {
+ @sortsiders=sort { $SortDir*$_sider_p{$a} <=> $SortDir*$_sider_p{$b} } keys (%_sider_p);
+ print "$CENTER
";
+ $tab_titre="$message[19]";
+ &tab_head;
+ print "| ".(@sortsiders)." $message[19] | $message[29] | |
\n";
+ if ($SortDir<0) { $max=$_sider_p{$sortsiders[0]}; }
+ else { $max=$_sider_p{$sortsiders[$#sortsiders]}; }
+ foreach $key (@sortsiders) {
+ print "| ";
+ $nompage=$Aliases{$key};
+ if ($nompage eq "") { $nompage=$key; }
+ $nompage=substr($nompage,0,$MaxLengthOfURL);
+ if ($ShowLinksOnUrl) { print "$nompage"; }
+ else { print "$nompage"; }
+ $bredde=$BarWidth*$_sider_p{$key}/$max+1;
+ print " | $_sider_p{$key} | ![\"$message[56]: \"$message[56]:](\"$DirIcons\/other\/$BarImageHorizontal_p\") |
\n";
+ }
+ &tab_end;
&html_end;
exit(0);
}
@@ -2464,7 +2564,7 @@ $tab_titre="$message[7] $SiteToAnalyze";
# FirstTime LastTime TotalVisits
$beginmonth=$MonthRequired;$endmonth=$MonthRequired;
if ($MonthRequired eq "year") { $beginmonth=1;$endmonth=12; }
-for ($monthix=$beginmonth; $monthix<=$endmonth; $monthix++) {
+for (my $monthix=$beginmonth; $monthix<=$endmonth; $monthix++) {
$monthix=$monthix+0; if ($monthix < 10) { $monthix = "0$monthix"; } # Good trick to change $month into "MM" format
if ($FirstTime{$YearRequired.$monthix} > 0 && ($FirstTime == 0 || $FirstTime > $FirstTime{$YearRequired.$monthix})) { $FirstTime = $FirstTime{$YearRequired.$monthix}; }
if ($LastTime < $LastTime{$YearRequired.$monthix}) { $LastTime = $LastTime{$YearRequired.$monthix}; }
@@ -2761,7 +2861,7 @@ print "$CENTER
";
$MaxNbOfPageShown = $TotalDifferentPages if $MaxNbOfPageShown > $TotalDifferentPages;
$tab_titre="TOP $MaxNbOfPageShown $message[55] $TotalDifferentPages $message[27]";
&tab_head;
-print "| Page-URL | $message[29] | |
\n";
+print "| $message[19] | $message[29] | |
\n";
if ($SortDir<0) { $max=$_sider_p{$sortsiders[0]}; }
else { $max=$_sider_p{$sortsiders[$#sortsiders]}; }
$count=0;
@@ -2843,7 +2943,6 @@ if ($TotalHits > 0) {
}
print "| $message[37] | $message[56] | $message[15] | $message[57] | $message[15] |
\n";
print "| $message[38]: | $_from_p[0] | $p_p[0] % | $_from_h[0] | $p_h[0] % |
\n";
-print "| $message[39]: | $_from_p[1] | $p_p[1] % | $_from_h[1] | $p_h[1] % |
\n";
#------- Referrals by search engine
print "$message[40] : \n";
print "\n";
@@ -2853,7 +2952,7 @@ foreach $se (@sortsereferrals) {
print " | \n";
print "$_from_p[2] | $p_p[2] % | $_from_h[2] | $p_h[2] % |
\n";
#------- Referrals by external HTML link
-print "$message[41] : \n";
+print " |
$message[41]: \n";
print "\n";
$count=0;
foreach $from (@sortpagerefs) {
@@ -2873,7 +2972,8 @@ foreach $from (@sortpagerefs) {
print " | \n";
print "$_from_p[3] | $p_p[3] % | $_from_h[3] | $p_h[3] % |
\n";
#------- Referrals by internal HTML link
-print "| $message[42] : | $_from_p[4] | $p_p[4] % | $_from_h[4] | $p_h[4] % |
\n";
+print "| $message[42]: | $_from_p[4] | $p_p[4] % | $_from_h[4] | $p_h[4] % |
\n";
+print "| $message[39]: | $_from_p[1] | $p_p[1] % | $_from_h[1] | $p_h[1] % |
\n";
&tab_end;
@@ -2922,6 +3022,8 @@ foreach $key (@sorterrors) {
}
&tab_end;
+#print "XXXXX Record $NbOfLinesRead{1}, file 1 is: $field[$pos_rc]{1} ; - ; - ; $field[$pos_date]{1} ; TZ; $field[$pos_method]{1} ; $field[$pos_url]{1} ; $field[$pos_code]{1} ; $field[$pos_size]{1} ; $field[$pos_referer]{1} ; $field[$pos_agent]{1}";
+
&html_end;
0; # Do not remove this line