--- ../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      */
