Package-Name: webalizer
Gentoo-Package: app-admin/webalizer
Requires: db gd libpng jpeg
Rebuild-For: db
Homepage: http://www.mrunix.net/webalizer/
Source: ftp://ftp.mrunix.net/pub/webalizer/webalizer-(\d+.\d+)-(\d+)-src.tgz $1.$2
Zap-Before-Install: 1
Repack:
	tar xzvfp "$(SOURCE)"
	test -d webalizer-"$(VERSION)" || mv webalizer* webalizer-"$(VERSION)"
Compile:
	cp -p CHANGES COPYING Copyright DNS.README README* sample.conf "$(PREFIX)/"
	umask 022 ; mkdir -p "$(PREFIX)"/{bin,etc,man/man1}
	$(MAKE) -f ../Makefile configure CONFIGURE_OPTS="--with-etcdir='$(PREFIX)/etc' --enable-dns"
	if packager c freetype ; then FREETYPE=-lfreetype ; else FREETYPE= ; fi ; \
	$(MAKE) MORELIBS="-ljpeg $$FREETYPE"
	$(MAKE) install
	if cmp "$(PREFIX)"/bin/{webalizer,webazolver} &>/dev/null ; then \
		ln -fs webalizer "$(PREFIX)"/bin/webazolver ; \
	fi
	test -f "$(PREFIX)"/etc/webalizer.conf || cp -p "$(PREFIX)"/etc/webalizer.conf.sample "$(PREFIX)"/etc/webalizer.conf
Install:
	$(MAKE) instbin BIN="webalizer webazolver"
	$(MAKE) instetc ETC=webalizer.conf LINK=webalizer.conf.sample
	$(MAKE) instman SECTION=1 MAN=webalizer
Patch: <<EOT
######## begin extended-history.diff
--- ../webalizer-2.01.10-orig/graphs.c	2001-06-15 17:34:24 +0900
+++ graphs.c	2007-12-18 05:33:44 +0900
@@ -177,7 +177,7 @@
    for (i=0; i<12; i++)
    {
       if (s_mth > 12) s_mth = 1;
-      percent = ((float)data1[s_mth++ -1] / (float)maxval);
+      percent = ((float)data1[i] / (float)maxval);
       if (percent <= 0.0) continue;
       x1 = 26 + (i*23);
       x2 = x1 + 13;
@@ -191,7 +191,7 @@
    for (i=0; i<12; i++)
    {
       if (s_mth > 12) s_mth = 1;
-      percent = ((float)data2[s_mth++ -1] / (float)maxval);
+      percent = ((float)data2[i] / (float)maxval);
       if (percent <= 0.0) continue;
       x1 = 29 + (i*23);
       x2 = x1 + 13;
@@ -205,7 +205,7 @@
    for (i=0; i<12; i++)
    {
       if (s_mth > 12) s_mth = 1;
-      percent = ((float)data5[s_mth++ -1] / (float)maxval);
+      percent = ((float)data5[i] / (float)maxval);
       if (percent <= 0.0) continue;
       x1 = 32 + (i*23);
       x2 = x1 + 13;
@@ -230,7 +230,7 @@
    for (i=0; i<12; i++)
    {
       if (s_mth > 12) s_mth = 1;
-      percent = ((float)data6[s_mth++ -1] / (float)maxval);
+      percent = ((float)data6[i] / (float)maxval);
       if (percent <= 0.0) continue;
       x1 = 310 + (i*15);
       x2 = x1 + 8;
@@ -244,7 +244,7 @@
    for (i=0; i<12; i++)
    {
       if (s_mth > 12) s_mth = 1;
-      percent = ((float)data3[s_mth++ -1] / (float)maxval);
+      percent = ((float)data3[i] / (float)maxval);
       if (percent <= 0.0) continue;
       x1 = 314 + (i*15);
       x2 = x1 + 7;
@@ -266,7 +266,7 @@
    for (i=0; i<12; i++)
    {
       if (s_mth > 12) s_mth = 1;
-      percent = ((float)data4[s_mth++ -1] / (float)fmaxval);
+      percent = ((float)data4[i] / (float)fmaxval);
       if (percent <= 0.0) continue;
       x1 = 311 + (i*15);
       x2 = x1 + 9;
--- ../webalizer-2.01.10-orig/output.c	2001-06-15 17:34:24 +0900
+++ output.c	2007-12-18 05:34:04 +0900
@@ -282,7 +282,7 @@
       printf("%s %s %d\n",msg_gen_rpt, l_month[cur_month-1], cur_year); 
 
    /* update history */
-   i=cur_month-1;
+   i=hist_count++;
    hist_month[i] =  cur_month;
    hist_year[i]  =  cur_year;
    hist_hit[i]   =  t_hit;
@@ -685,10 +685,10 @@
    fprintf(out_fp,"<TR><TH HEIGHT=4></TH></TR>\n");
 
    /* skip beginning blank days in a month */
-   for (i=0;i<hist_lday[cur_month-1];i++) if (tm_hit[i]!=0) break;
-   if (i==hist_lday[cur_month-1]) i=0;
+   for (i=0;i<hist_lday[hist_count-1];i++) if (tm_hit[i]!=0) break;
+   if (i==hist_lday[hist_count-1]) i=0;
 
-   for (;i<hist_lday[cur_month-1];i++)
+   for (;i<hist_lday[hist_count-1];i++)
    {
       fprintf(out_fp,"<TR><TD ALIGN=center>"                                 \
               "<FONT SIZE=\"-1\"><B>%d</B></FONT></TD>\n", i+1);
@@ -2302,6 +2302,7 @@
    int  i,days_in_month;
    int  lyear=0;
    int	s_mth=0;
+   int  entry=0;
    double  gt_hit=0.0;
    double  gt_files=0.0;
    double  gt_pages=0.0;
@@ -2314,14 +2315,16 @@
 
    sprintf(buffer,"%s %s",msg_main_us,hname);
 
-   for (i=0;i<12;i++)                   /* get last month in history */
+   for (i=0;i<hist_count;i++)           /* get last month in history */
    {
       if (hist_year[i]>lyear)
        { lyear=hist_year[i]; s_mth=hist_month[i]; }
       if (hist_year[i]==lyear)
       {
-         if (hist_month[i]>=s_mth)
+         if (hist_month[i]>=s_mth) {
             s_mth=hist_month[i];
+            entry=i;
+         }
       }
    }
 
@@ -2330,12 +2333,12 @@
    year_graph6x(   "usage.png",         /* filename          */
                    buffer,              /* graph title       */
                    i,                   /* last month        */
-                   hist_hit,            /* data set 1        */
-                   hist_files,          /* data set 2        */
-                   hist_site,           /* data set 3        */
-                   hist_xfer,           /* data set 4        */
-                   hist_page,           /* data set 5        */
-                   hist_visit);         /* data set 6        */
+                   hist_hit+hist_count-12,/* data set 1        */
+                   hist_files+hist_count-12,/* data set 2        */
+                   hist_site+hist_count-12,/* data set 3        */
+                   hist_xfer+hist_count-12,/* data set 4        */
+                   hist_page+hist_count-12,/* data set 5        */
+                   hist_visit+hist_count-12);/* data set 6        */
 
    /* now do html stuff... */
    sprintf(index_fname,"index.%s",html_ext);
@@ -2383,40 +2386,41 @@
    fprintf(out_fp,"<TH ALIGN=center BGCOLOR=\"%s\">"                      \
           "<FONT SIZE=\"-1\">%s</FONT></TH></TR>\n",DKGREEN,msg_h_hits);
    fprintf(out_fp,"<TR><TH HEIGHT=4></TH></TR>\n");
-   for (i=0;i<12;i++)
+   for (i=0;i<num_months;i++)
    {
-      if (--s_mth < 0) s_mth = 11;
-      if ((hist_month[s_mth]==0) && (hist_files[s_mth]==0)) continue;
-      days_in_month=(hist_lday[s_mth]-hist_fday[s_mth])+1;
+      if ((hist_month[entry]==0) && (hist_files[entry]==0)) continue;
+      days_in_month=(hist_lday[entry]-hist_fday[entry])+1;
       fprintf(out_fp,"<TR><TD NOWRAP><A HREF=\"usage_%04d%02d.%s\">"      \
                      "<FONT SIZE=\"-1\">%s %d</FONT></A></TD>\n",
-                      hist_year[s_mth], hist_month[s_mth], html_ext,
-                      s_month[hist_month[s_mth]-1], hist_year[s_mth]);
+                      hist_year[entry], hist_month[entry], html_ext,
+                      s_month[hist_month[entry]-1], hist_year[entry]);
       fprintf(out_fp,"<TD ALIGN=right><FONT SIZE=\"-1\">%lu</FONT></TD>\n",
-                      hist_hit[s_mth]/days_in_month);
+                      hist_hit[entry]/days_in_month);
       fprintf(out_fp,"<TD ALIGN=right><FONT SIZE=\"-1\">%lu</FONT></TD>\n",
-                      hist_files[s_mth]/days_in_month);
+                      hist_files[entry]/days_in_month);
       fprintf(out_fp,"<TD ALIGN=right><FONT SIZE=\"-1\">%lu</FONT></TD>\n",
-                      hist_page[s_mth]/days_in_month);
+                      hist_page[entry]/days_in_month);
       fprintf(out_fp,"<TD ALIGN=right><FONT SIZE=\"-1\">%lu</FONT></TD>\n",
-                      hist_visit[s_mth]/days_in_month);
+                      hist_visit[entry]/days_in_month);
       fprintf(out_fp,"<TD ALIGN=right><FONT SIZE=\"-1\">%lu</FONT></TD>\n",
-                      hist_site[s_mth]);
+                      hist_site[entry]);
       fprintf(out_fp,"<TD ALIGN=right><FONT SIZE=\"-1\">%.0f</FONT></TD>\n",
-                      hist_xfer[s_mth]);
+                      hist_xfer[entry]);
       fprintf(out_fp,"<TD ALIGN=right><FONT SIZE=\"-1\">%lu</FONT></TD>\n",
-                      hist_visit[s_mth]);
+                      hist_visit[entry]);
       fprintf(out_fp,"<TD ALIGN=right><FONT SIZE=\"-1\">%lu</FONT></TD>\n",
-                      hist_page[s_mth]);
+                      hist_page[entry]);
       fprintf(out_fp,"<TD ALIGN=right><FONT SIZE=\"-1\">%lu</FONT></TD>\n",
-                      hist_files[s_mth]);
+                      hist_files[entry]);
       fprintf(out_fp,"<TD ALIGN=right><FONT SIZE=\"-1\">%lu</FONT></TD></TR>\n",
-                      hist_hit[s_mth]);
-      gt_hit   += hist_hit[s_mth];
-      gt_files += hist_files[s_mth];
-      gt_pages += hist_page[s_mth];
-      gt_xfer  += hist_xfer[s_mth];
-      gt_visits+= hist_visit[s_mth];
+                      hist_hit[entry]);
+      gt_hit   += hist_hit[entry];
+      gt_files += hist_files[entry];
+      gt_pages += hist_page[entry];
+      gt_xfer  += hist_xfer[entry];
+      gt_visits+= hist_visit[entry];
+      if (--entry < 0)
+         break;
    }
    fprintf(out_fp,"<TR><TH HEIGHT=4></TH></TR>\n");
    fprintf(out_fp,"<TR><TH BGCOLOR=\"%s\" COLSPAN=6 ALIGN=left>"          \
--- ../webalizer-2.01.10-orig/preserve.c	2001-10-24 15:22:42 +0900
+++ preserve.c	2007-12-18 05:33:44 +0900
@@ -66,15 +66,19 @@
 #include "preserve.h"
 
 /* local variables */
-int     hist_month[12], hist_year[12];        /* arrays for monthly total */
-u_long  hist_hit[12];                         /* calculations: used to    */
-u_long  hist_files[12];                       /* produce index.html       */
-u_long  hist_site[12];                        /* these are read and saved */
-double  hist_xfer[12];                        /* in the history file      */
-u_long  hist_page[12];
-u_long  hist_visit[12];
+int     hist_month[HIST_SIZE];                /* arrays for monthly total */
+int     hist_year[HIST_SIZE];
+u_long  hist_hit[HIST_SIZE];                  /* calculations: used to    */
+u_long  hist_files[HIST_SIZE];                /* produce index.html       */
+u_long  hist_site[HIST_SIZE];                 /* these are read and saved */
+double  hist_xfer[HIST_SIZE];                 /* in the history file      */
+u_long  hist_page[HIST_SIZE];
+u_long  hist_visit[HIST_SIZE];
 
-int     hist_fday[12], hist_lday[12];         /* first/last day arrays    */
+int     hist_fday[HIST_SIZE];                 /* first/last day arrays    */
+int     hist_lday[HIST_SIZE];
+
+int     hist_count;                           /* number of entries        */
 
 /*********************************************/
 /* GET_HISTORY - load in history file        */
@@ -87,7 +91,7 @@
    char buffer[BUFSIZE];
 
    /* first initalize internal array */
-   for (i=0;i<12;i++)
+   for (i=0;i<HIST_SIZE;i++)
    {
       hist_month[i]=hist_year[i]=hist_fday[i]=hist_lday[i]=0;
       hist_hit[i]=hist_files[i]=hist_site[i]=hist_page[i]=hist_visit[i]=0;
--- ../webalizer-2.01.10-orig/preserve.h	2000-09-29 12:50:31 +0900
+++ preserve.h	2007-12-18 05:33:44 +0900
@@ -6,16 +6,19 @@
 extern int     save_state();                  /* save run state           */
 extern int     restore_state();               /* restore run state        */
 
-extern int     hist_month[12];                /* arrays for monthly total */
-extern int     hist_year[12];
-extern u_long  hist_hit[12];                  /* calculations: used to    */
-extern u_long  hist_files[12];                /* produce index.html       */
-extern u_long  hist_site[12];                 /* these are read and saved */
-extern double  hist_xfer[12];                 /* in the history file      */
-extern u_long  hist_page[12];
-extern u_long  hist_visit[12];
+#define HIST_SIZE 256
+extern int     hist_month[HIST_SIZE];         /* arrays for monthly total */
+extern int     hist_year[HIST_SIZE];
+extern u_long  hist_hit[HIST_SIZE];           /* calculations: used to    */
+extern u_long  hist_files[HIST_SIZE];         /* produce index.html       */
+extern u_long  hist_site[HIST_SIZE];          /* these are read and saved */
+extern double  hist_xfer[HIST_SIZE];          /* in the history file      */
+extern u_long  hist_page[HIST_SIZE];
+extern u_long  hist_visit[HIST_SIZE];
 
-extern int     hist_fday[12];                 /* first/last day arrays    */
-extern int     hist_lday[12];
+extern int     hist_fday[HIST_SIZE];          /* first/last day arrays    */
+extern int     hist_lday[HIST_SIZE];
+
+extern int     hist_count;                    /* number of entries        */
 
 #endif  /* _PRESERVE_H */
--- ../webalizer-2.01.10-orig/webalizer.c	2002-04-17 07:11:31 +0900
+++ webalizer.c	2007-12-18 05:33:44 +0900
@@ -167,6 +167,8 @@
 int     dump_header  = 0;                     /* Dump header as first rec */
 char    *dump_path   = NULL;                  /* Path for dump files      */
 
+int     num_months   = 12;                    /* # of months in index     */
+
 int     cur_year=0, cur_month=0,              /* year/month/day/hour      */
         cur_day=0, cur_hour=0,                /* tracking variables       */
         cur_min=0, cur_sec=0;
@@ -1449,7 +1451,8 @@
                      "DNSCache",          /* DNS Cache file name        84  */
                      "DNSChildren",       /* DNS Children (0=no DNS)    85  */
                      "DailyGraph",        /* Daily Graph (0=no)         86  */
-                     "DailyStats"         /* Daily Stats (0=no)         87  */
+                     "DailyStats",        /* Daily Stats (0=no)         87  */
+                     "Months",            /* Number of months in index  88  */
                    };
 
    FILE *fp;
@@ -1593,6 +1596,12 @@
 #endif  /* USE_DNS */
         case 86: daily_graph=(value[0]=='n')?0:1; break;  /* HourlyGraph    */
         case 87: daily_stats=(value[0]=='n')?0:1; break;  /* HourlyStats    */
+        case 88: num_months=atoi(value);
+                 if (num_months<0 || num_months>HIST_SIZE) {
+                     printf("%s '%s' (%s)\n",msg_bad_key,keyword,fname);
+                     num_months=12;
+                 }
+                 break;
       }
    }
    fclose(fp);
--- ../webalizer-2.01.10-orig/webalizer.h	2001-02-10 09:58:18 +0900
+++ webalizer.h	2007-12-18 05:33:44 +0900
@@ -219,6 +219,8 @@
 extern int     dump_header  ;                 /* Dump header as first rec */
 extern char    *dump_path   ;                 /* Path for dump files      */
 
+extern int     num_months   ;                 /* # of months in index     */
+
 extern u_long  cur_tstamp;                    /* Current timestamp        */
 extern u_long  epoch;                         /* used for timestamp adj.  */
 extern int     check_dup;                     /* check for dups flag      */
######## end extended-history.diff
######## begin timezones.diff
--- ../webalizer-2.01.10-orig/webalizer.c	2002-04-17 07:11:31 +0900
+++ webalizer.c	2007-11-25 01:12:11 +0900
@@ -242,7 +242,7 @@
    float  temp_time;                     /* temporary time storage      */
    struct tms     mytms;                 /* bogus tms structure         */
 
-   int    rec_year,rec_month=1,rec_day,rec_hour,rec_min,rec_sec;
+   int    rec_year,rec_month=1,rec_day,rec_hour,rec_min,rec_sec,rec_ofs;
 
    int    good_rec    =0;                /* 1 if we had a good record   */
    u_long total_rec   =0;                /* Total Records Processed     */
@@ -469,8 +469,8 @@
    if (dns_cache && dns_children)    /* run-time resolution */
    {
       if (dns_children > MAXCHILD) dns_children=MAXCHILD;
-      /* DNS Lookup (#children): */
-      if (verbose>1) printf("%s (%d): ",msg_dns_rslv,dns_children);
+      /* DNS Lookup (#children)... */
+      if (verbose>1) printf("%s (%d)...\n",msg_dns_rslv,dns_children);
       fflush(stdout);
       (gz_log)?dns_resolver(gzlog_fp):dns_resolver(log_fp);
       (gz_log)?gzrewind(gzlog_fp):(log_fname)?rewind(log_fp):exit(0);
@@ -583,6 +583,9 @@
          rec_hour=atoi(&log_rec.datetime[13]);   /* get hour number         */
          rec_min =atoi(&log_rec.datetime[16]);   /* get minute number       */
          rec_sec =atoi(&log_rec.datetime[19]);   /* get second number       */
+         rec_ofs =atoi(&log_rec.datetime[23]);   /* get GMT offset          */
+         rec_ofs=(rec_ofs/100)*60+(rec_ofs%100);
+         if (log_rec.datetime[22]=='-') rec_ofs=-rec_ofs;
 
          /* Kludge for Netscape server time (0-24?) error                   */
          if (rec_hour>23) rec_hour=0;
@@ -612,6 +615,19 @@
          req_tstamp=cur_tstamp;
          rec_tstamp=((jdate(rec_day,rec_month,rec_year)-epoch)*86400)+
                      (rec_hour*3600)+(rec_min*60)+rec_sec;
+         rec_tstamp-=rec_ofs*60;
+
+         /* Now convert the timestamp to local time */
+         {
+            time_t t = rec_tstamp;
+            struct tm *tm = localtime(&t);
+            rec_sec   = tm->tm_sec;
+            rec_min   = tm->tm_min;
+            rec_hour  = tm->tm_hour;
+            rec_day   = tm->tm_mday;
+            rec_month = tm->tm_mon+1;
+            rec_year  = tm->tm_year+1900;
+         }
 
          /* Do we need to check for duplicate records? (incremental mode)   */
          if (check_dup)
@@ -647,7 +663,12 @@
          if (rec_tstamp/3600 < cur_tstamp/3600)
          {
             if (!fold_seq_err && ((rec_tstamp+SLOP_VAL)/3600<cur_tstamp/3600) )
-               { total_ignore++; continue; }
+            {
+               if (debug_mode)
+                  fprintf(stderr, "Ignoring out-of-sequence record (%d)\n", total_rec);
+               total_ignore++;
+               continue;
+            }
             else
             {
                rec_sec   = cur_sec;             /* if folding sequence      */
######## end timezones.diff
######## remainder is local stuff
--- webalizer.h.old	2001-02-10 09:58:18 +0900
+++ webalizer.h	2007-12-18 05:50:45 +0900
@@ -11,16 +11,16 @@
 #endif
 
 #define MAXHASH  2048                  /* Size of our hash tables          */
-#define BUFSIZE  4096                  /* Max buffer size for log record   */
+#define BUFSIZE  8192                  /* Max buffer size for log record   */
 #define MAXHOST  128                   /* Max hostname buffer size         */
 #define MAXURL   1024                  /* Max HTTP request/URL field size  */
 #define MAXURLH  128                   /* Max URL field size in htab       */
-#define MAXREF   1024                  /* Max referrer field size          */
+#define MAXREF   4096                  /* Max referrer field size          */
-#define MAXREFH  128                   /* Max referrer field size in htab  */
+#define MAXREFH  256                   /* Max referrer field size in htab  */
 #define MAXAGENT 64                    /* Max user agent field size        */
 #define MAXCTRY  48                    /* Max country name size            */
 #define MAXSRCH  256                   /* Max size of search string buffer */
-#define MAXSRCHH 64                    /* Max size of search str in htab   */
+#define MAXSRCHH 256                   /* Max size of search str in htab   */
 #define MAXIDENT 64                    /* Max size of ident string (user)  */
 
 #define SLOP_VAL 3600                  /* out of sequence slop (seconds)   */
--- configure.old	Fri Oct  6 16:51:48 2000
+++ configure	Thu Nov 14 06:41:56 2002
@@ -1199,13 +1199,10 @@
 cat > conftest.$ac_ext <<EOF
 #line 1201 "configure"
 #include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error.  */
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char dbopen();
+#include <db_185.h>
 
 int main() {
-dbopen()
+dbopen(0,0,0,0,0)
 ; return 0; }
 EOF
 if { (eval echo configure:1212: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
@@ -1221,13 +1218,10 @@
 cat > conftest.$ac_ext <<EOF
 #line 1223 "configure"
 #include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error.  */
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char dbopen();
+#include <db_185.h>
 
 int main() {
-dbopen()
+dbopen(0,0,0,0,0)
 ; return 0; }
 EOF
 if { (eval echo configure:1234: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
--- Makefile.in.old	Tue Oct 17 13:15:53 2000
+++ Makefile.in	Thu Nov 14 00:10:06 2002
@@ -43,7 +43,7 @@
                 dns_resolv.o dns_resolv.h parser.o parser.h  \
                 output.o output.h graphs.o graphs.h lang.h   \
 		webalizer_lang.h
-	$(CC) ${LDFLAGS} -o webalizer webalizer.o hashtab.o linklist.o preserve.o parser.o output.o dns_resolv.o graphs.o ${LIBS}
+	$(CC) ${LDFLAGS} -o webalizer webalizer.o hashtab.o linklist.o preserve.o parser.o output.o dns_resolv.o graphs.o ${LIBS} ${MORELIBS}
 	rm -f webazolver
 	@LN_S@ webalizer webazolver
 
EOT

-/etc/webalizer.conf
/etc/webalizer.conf
/etc/webalizer.conf.sample
/pkg/webalizer/
/usr/bin/webalizer
/usr/bin/webazolver
/usr/man/man1/webalizer.1.gz
