]> git.ipfire.org Git - thirdparty/sarg.git/blobdiff - index.c
Remove any limit on the maximum URL length (bugs remain)
[thirdparty/sarg.git] / index.c
diff --git a/index.c b/index.c
index c4b37cfa2cbdb9c28a1be61de74dd93118ec5dbc..9b7a82bc8b4b8b3df585a289b5a614df5392fe40 100644 (file)
--- a/index.c
+++ b/index.c
@@ -40,7 +40,7 @@ void make_index(void)
 
    if(LastLog > 0) mklastlog(outdir);
 
-   if(strcmp(Index,"no") == 0) {
+   if(Index == INDEX_NO) {
       sprintf(wdir,"%sindex.html",outdir);
       if(access(wdir, R_OK) == 0) unlink(wdir);
       return;
@@ -52,7 +52,7 @@ void make_index(void)
    dirp = opendir(outdir);
    while ((direntp = readdir( dirp )) != NULL) {
       if(isdigit(direntp->d_name[0]) && isdigit(direntp->d_name[1])) {
-         if(strcmp(IndexTree,"date") == 0)
+         if(IndexTree == INDEX_TREE_DATE)
             file_index_to_date_index(direntp->d_name);
          else
             date_index_to_file_index(direntp->d_name);
@@ -60,7 +60,7 @@ void make_index(void)
    }
    closedir(dirp);
 
-   if(strcmp(IndexTree,"date") == 0) {
+   if(IndexTree == INDEX_TREE_DATE) {
       make_date_index();
    } else {
       make_file_index();
@@ -74,7 +74,6 @@ static void make_date_index(void)
    struct dirent *direntp;
    struct dirent *direntp2;
    struct dirent *direntp3;
-   char hbc1[30];
    char yearindex[MAXLEN];
    char yeardir[MAXLEN];
    char yearnum[10];
@@ -85,6 +84,7 @@ static void make_date_index(void)
    char monthnum[10];
    char dayindex[MAXLEN];
    char daynum[10];
+   char title[80];
    int yearsort[150];
    int nyears;
    int year;
@@ -98,7 +98,6 @@ static void make_date_index(void)
    int order;
 
    sprintf(yearindex,"%sindex.html",outdir);
-   strcpy(hbc1,"class=\"header\"");
 
    nyears=0;
    dirp = opendir(outdir);
@@ -133,8 +132,10 @@ static void make_date_index(void)
       fprintf(stderr, "SARG: (index) %s: %s - %s\n",text[45],yearindex,strerror(errno));
       exit(1);
    }
-   write_html_header(fp_ou, ".");
-   fprintf(fp_ou,"<tr><th %s>%s</th><th %s>%s</th></tr>\n",hbc1,text[130],hbc1,text[132]);
+   write_html_header(fp_ou,0,"SARG reports");
+   close_html_header(fp_ou);
+   fputs("<div class=\"index\"><table cellpadding=\"1\" cellspacing=\"2\">\n<tr><td></td><td></td></tr>\n",fp_ou);
+   fprintf(fp_ou,"<tr><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th></tr>\n",text[130],text[132]);
    for (y=0 ; y<nyears ; y++) {
       if (order>0)
          year=yearsort[y];
@@ -174,8 +175,11 @@ static void make_date_index(void)
          fprintf(stderr, "SARG: (index) %s: %s - %s\n",text[45],monthindex,strerror(errno));
          exit(1);
       }
-      write_html_header(fp_ou2,"..");
-      fprintf(fp_ou2,"<tr><th %s>%s/%s</th></tr>\n",hbc1,text[130],text[131]);
+      snprintf(title,sizeof(title),"SARG: report for %04d",year);
+      write_html_header(fp_ou2,1,title);
+      close_html_header(fp_ou2);
+      fputs("<div class=\"index\"><table cellpadding=\"1\" cellspacing=\"2\">\n<tr><td></td><td></td></tr>\n",fp_ou2);
+      fprintf(fp_ou2,"<tr><th class=\"header_l\">%s/%s</th></tr>\n",text[130],text[131]);
       for (m=0 ; m<nmonths ; m++) {
          if (order>0)
             month=monthsort[m];
@@ -229,8 +233,11 @@ static void make_date_index(void)
             fprintf(stderr, "SARG: (index) %s: %s - %s\n",text[45],dayindex,strerror(errno));
             exit(1);
          }
-         write_html_header(fp_ou3,"../..");
-         fprintf(fp_ou3,"<tr><th %s>%s/%s/%s</th></tr>\n",hbc1,text[130],text[131],text[127]);
+         snprintf(title,sizeof(title),"SARG: report for %04d/%02d",year,month);
+         write_html_header(fp_ou3,2,title);
+         close_html_header(fp_ou3);
+         fputs("<div class=\"index\"><table cellpadding=\"1\" cellspacing=\"2\">\n<tr><td></td><td></td></tr>\n",fp_ou3);
+         fprintf(fp_ou3,"<tr><th class=\"header_l\">%s/%s/%s</th></tr>\n",text[130],text[131],text[127]);
          for (d=0 ; d<ndays ; d++) {
             if (order>0)
                day=daysort[d];
@@ -245,13 +252,16 @@ static void make_date_index(void)
             }
             fprintf(fp_ou3,"<tr><td class=\"data2\"><a href=\"%s/index.html\">%s %s %s</a></td></tr>\n",daynum,yearnum,nmonth,daynum);
          }
+         fputs("</table></div>\n",fp_ou3);
          write_html_trailer(fp_ou3);
          fclose(fp_ou3);
       }
+      fputs("</table></div>\n",fp_ou2);
       write_html_trailer(fp_ou2);
       fclose(fp_ou2);
    }
 
+   fputs("</table></div>\n",fp_ou);
    write_html_trailer(fp_ou);
    fclose(fp_ou);
 }
@@ -287,7 +297,6 @@ static void make_file_index(void)
    } **sortlist, *item, **tempsort;
 
    sprintf(wdir,"%sindex.html",outdir);
-   strcpy(hbc1,"class=\"header\"");
 
    order=(strcmp(IndexSortOrder,"A") == 0) ? 1 : -1;
 
@@ -327,29 +336,29 @@ static void make_file_index(void)
          */
          getword_start(&gwarea,data);
          if (getword_skip(16,&gwarea,' ')<0) {
-            printf("SARG: Maybe you have a broken week day in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
+            debuga(_("Maybe you have a broken week day in your %s%s/sarg-date file"),outdir,direntp->d_name);
             exit(1);
          }
          if (getword_multisep(mon,sizeof(mon),&gwarea,' ')<0) {
-            printf("SARG: Maybe you have a broken month in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
+            debuga(_("Maybe you have a broken month in your %s%s/sarg-date file"),outdir,direntp->d_name);
             exit(1);
          }
          if (getword_multisep(day,sizeof(day),&gwarea,' ')<0) {
-            printf("SARG: Maybe you have a broken day in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
+            debuga(_("Maybe you have a broken day in your %s%s/sarg-date file"),outdir,direntp->d_name);
             exit(1);
          }
          if (getword_multisep(hour,sizeof(hour),&gwarea,' ')<0) {
-            printf("SARG: Maybe you have a broken time in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
+            debuga(_("Maybe you have a broken time in your %s%s/sarg-date file"),outdir,direntp->d_name);
             exit(1);
          }
          do {
             if (getword_multisep(year,sizeof(year),&gwarea,' ')<0) {
-               printf("SARG: Maybe you have a broken year in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
+               debuga(_("Maybe you have a broken year in your %s%s/sarg-date file"),outdir,direntp->d_name);
                exit(1);
             }
          } while (year[0] && !isdigit(year[0])); //skip time zone information with spaces until the year is found
          if (sscanf(hour,"%d:%d:%d",&ihour,&iminute,&isecond)!=3) {
-            printf("SARG: Maybe you have a broken time in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
+            debuga(_("Maybe you have a broken time in your %s%s/sarg-date file"),outdir,direntp->d_name);
             exit(1);
          }
          buildymd(day,mon,year,ftime);
@@ -384,8 +393,10 @@ static void make_file_index(void)
       fprintf(stderr, "SARG: (index) %s: %s\n",text[45],wdir);
       exit(1);
    }
-   write_html_header(fp_ou,".");
-   fprintf(fp_ou,"<tr><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th></tr>\n",hbc1,text[101],hbc1,text[102],hbc1,text[103],hbc1,text[93],hbc1,text[96]);
+   write_html_header(fp_ou,0,"SARG reports");
+   close_html_header(fp_ou);
+   fputs("<div class=\"index\"><table cellpadding=\"1\" cellspacing=\"2\">\n<tr><td></td><td></td></tr>\n",fp_ou);
+   fprintf(fp_ou,"<tr><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th></tr>\n",text[101],text[102],text[103],text[93],text[96]);
    for (i=0 ; i<nsort ; i++) {
       if (order>0)
          item=sortlist[i];
@@ -395,6 +406,7 @@ static void make_file_index(void)
       obttotal(outdir,item->dirname,tbytes,tuser,media);
       fprintf(fp_ou,"<tr><td class=\"data2\"><a href='%s/%s'>%s</a></td><td class=\"data2\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td></tr>\n",item->dirname,ReplaceIndex,item->dirname,item->date,tuser,tbytes,media);
    }
+   fputs("</table></div>\n",fp_ou);
    write_html_trailer(fp_ou);
    fclose(fp_ou);