]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Don't show empty colums when columns are not requested in sarg.conf
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Thu, 28 Jan 2010 20:28:48 +0000 (20:28 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Thu, 28 Jan 2010 20:28:48 +0000 (20:28 +0000)
CMakeLists.txt
html.c
include/conf.h

index d5724e8200c9103010278318a5c24aa4edf4a11c..163a0b9c898741544a7d2758ac1b7fadd7a1c93a 100755 (executable)
@@ -1,7 +1,7 @@
 CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
 PROJECT(sarg C)
 SET(sarg_VERSION 2)
-SET(sarg_REVISION 3)
+SET(sarg_REVISION "3rc1")
 SET(sarg_BUILD "")
 SET(sarg_BUILDDATE "Jan-28-2010")
 
@@ -17,7 +17,7 @@ DEFINE_PROPERTY(GLOBAL PROPERTY enable-htmldir BRIEF_DOCS "--enable-htmldir=html
                         FULL_DOCS "Select htmldir as the root of your WWW documents")
 
 SET(PACKAGE_NAME "sarg")
-SET(PACKAGE_VERSION "${sarg_VERSION}.${sarg_REVISION}.${sarg_BUILD}")
+SET(PACKAGE_VERSION "${sarg_VERSION}.${sarg_REVISION}${sarg_BUILD}")
 
 MACRO(SET_ABS_SOURCE VAR DOC)
    IF(${VAR} AND NOT ${VAR}_SOURCE)
diff --git a/html.c b/html.c
index b74a52b86dbbed134306e65b5b9c26901cb01c62..4e1f188ba1232f0be4e6d4e50a60de2248480ae0 100644 (file)
--- a/html.c
+++ b/html.c
@@ -55,7 +55,6 @@ void htmlrel(void)
    int cstatus;
    const char txtext[]=".txt";
    int dlen;
-   char href2[MAXLEN];
    char urly[MAXLEN];
    char siteind[MAXLEN];
    struct getwordstruct gwarea;
@@ -254,35 +253,24 @@ void htmlrel(void)
          fprintf(fp_ou,"<tr><td class=\"header\" colspan=\"11\"><a href=\"denied_%s.html\">%s</a> %s</td></tr>\n",denied_report,text[116],text[55]);
       }
 
-      strcpy(val3,text[92]);
-      strcpy(val4,text[93]);
-      sprintf(val11,"%%%s",text[93]);
-      sprintf(val5,"%s-%s-%s",text[113],text[114],text[112]);
-      strcpy(val6,text[94]);
-      strcpy(val7,text[95]);
-      sprintf(val8,"%%%s",text[99]);
-      strcpy(val9,"colspan=\"2\"");
-      bzero(val10, 255);
-
-      if((UserReportFields & USERREPORTFIELDS_CONNECT) == 0)
-         bzero(val3, 255);
-      if((UserReportFields & USERREPORTFIELDS_BYTES) == 0)
-         bzero(val4, 255);
-      if((UserReportFields & USERREPORTFIELDS_SETYB) == 0)
-         bzero(val11, 255);
-      if((UserReportFields & USERREPORTFIELDS_IN_CACHE_OUT) == 0) {
-         bzero(val5, 255);
-         bzero(val9, 255);
-         strcpy(val10,"<td></td>");
-      }
-      if((UserReportFields & USERREPORTFIELDS_USED_TIME) == 0)
-         bzero(val6, 255);
-      if((UserReportFields & USERREPORTFIELDS_MILISEC) == 0)
-         bzero(val7, 255);
-      if((UserReportFields & USERREPORTFIELDS_PTIME) == 0)
-         bzero(val8, 255);
-
-      fprintf(fp_ou,"<tr><th></th><th class=\"header\">%s</th><th class=\"header\">%s</th><th class=\"header\">%s</th><th class=\"header\">%s</th><th class=\"header3\" %s>%s</th><th class=\"header\">%s</th><th class=\"header\">%s</th><th class=\"header\">%s</th></tr>\n",text[91],val3,val4,val11,val9,val5,val6,val7,val8);
+      fprintf(fp_ou,"<tr><th></th><th class=\"header\">%s</th>",text[91]);
+
+      if((UserReportFields & USERREPORTFIELDS_CONNECT) != 0)
+         fprintf(fp_ou,"<th class=\"header\">%s</th>",text[92]);
+      if((UserReportFields & USERREPORTFIELDS_BYTES) != 0)
+         fprintf(fp_ou,"<th class=\"header\">%s</th>",text[93]);
+      if((UserReportFields & USERREPORTFIELDS_SETYB) != 0)
+         fprintf(fp_ou,"<th class=\"header\">%%%s</th>",text[93]);
+      if((UserReportFields & USERREPORTFIELDS_IN_CACHE_OUT) != 0)
+         fprintf(fp_ou,"<th class=\"header3\" colspan=\"2\">%s-%s-%s</th>",text[113],text[114],text[112]);
+      if((UserReportFields & USERREPORTFIELDS_USED_TIME) != 0)
+         fprintf(fp_ou,"<th class=\"header\">%s</th>",text[94]);
+      if((UserReportFields & USERREPORTFIELDS_MILISEC) != 0)
+         fprintf(fp_ou,"<th class=\"header\">%s</th>",text[95]);
+      if((UserReportFields & USERREPORTFIELDS_PTIME) != 0)
+         fprintf(fp_ou,"<th class=\"header\">%%%s</th>",text[99]);
+
+      fputs("</tr>\n",fp_ou);
 
       if(debug) {
          if(userip) {
@@ -324,10 +312,6 @@ void htmlrel(void)
             exit(1);
          }
 
-         if(strncmp(tmsg,"OK",2) != 0)
-            sprintf(tmsg,"<td class=\"data\">%s</td>",text[46]);
-         else bzero(tmsg, 50);
-
          if(nnbytes) {
             perc=nnbytes * 100;
             perc=perc / tnbytes;
@@ -351,98 +335,73 @@ void htmlrel(void)
             ouperc=ouperc / nnbytes;
          } else ouperc=0;
 
-         strcpy(wwork1,fixnum(twork,1));
-         strcpy(wwork2,fixnum(nnbytes,1));
-         strcpy(wwork3,fixnum2(nnelap,1));
-
-         if(!LongUrl) {
-            char *endofhost=strchr(url,'/');
-            if (endofhost) *endofhost='\0';
-            strcpy(urly,url);
-         } else {
-            strcpy(urly,url);
-            url_module(url, module);
-            str=strchr(url,'/');
-            if (str){
-               *str='\0';
-               strcat(url,"...");
-               strcat(url,module);
-            }
-         }
+         if(UserReportLimit<=0 || count<=UserReportLimit) {
+            fputs("<tr>",fp_ou);
 
-         if(Privacy)
-            sprintf(httplink,"<span style=\"color:%s;\">%s</span>",PrivacyStringColor,PrivacyString);
-         else {
             if(IndexTree == INDEX_TREE_DATE)
                sprintf(tmp6,"../%s",ImageFile);
             else
                strcpy(tmp6,"../../images");
-            if(BlockIt[0]!='\0')
-               snprintf(httplink,sizeof(httplink),"<a href=\"%s%s?url=%s\"><img src=\"%s/sarg-squidguard-block.png\" border=\"0\"></a><a href=http://%s>&nbsp;%s</a>",wwwDocumentRoot,BlockIt,urly,tmp6,urly,urly);
-            else
-               snprintf(httplink,sizeof(httplink),"<a href=\"http://%s\" title=\"%s\">%s</a>",urly,urly,url);
-         }
 
-         if((ReportType & REPORT_TYPE_SITE_USER_TIME_DATE) != 0) {
-            strcpy(ltext110,text[110]);
-            for(s=ltext110; *s; ++s)
-               *s=tolower(*s);
-            strcpy(siteind,urly);
-            str=siteind;
-            for(z1=0; str[z1]; z1++) {
-               if(str[z1]=='?' || str[z1]=='-' || str[z1]=='.' || str[z1]==':' || str[z1]=='/' || str[z1]=='\\' || str[z1]=='*' ||
-                  str[z1]=='\'' || str[z1]=='\"' || str[z1]=='$' || str[z1]=='@')
-                  str[z1]='_';
+            if((ReportType & REPORT_TYPE_SITE_USER_TIME_DATE) != 0) {
+               strcpy(ltext110,text[110]);
+               for(s=ltext110; *s; ++s)
+                  *s=tolower(*s);
+               strcpy(siteind,urly);
+               str=siteind;
+               for(z1=0; str[z1]; z1++) {
+                  if(str[z1]=='?' || str[z1]=='-' || str[z1]=='.' || str[z1]==':' || str[z1]=='/' || str[z1]=='\\' || str[z1]=='*' ||
+                     str[z1]=='\'' || str[z1]=='\"' || str[z1]=='$')
+                     str[z1]='_';
+               }
+               fprintf(fp_ou,"<td class=\"data\"><a href=\"tt%s-%s.html\"><img src=\"%s/datetime.png\" border=\"0\" title=\"%s %s\" alt=\"T\"></a></td>",usuario,siteind,tmp6,ltext110,text[55]);
+            } else {
+               fprintf(fp_ou,"<td class=\"data\"></td>");
             }
-            sprintf(href2,"<a href=\"tt%s-%s.html\"><img src=\"%s/datetime.png\" border=\"0\" title=\"%s %s\" alt=\"T\"></a>",usuario,siteind,tmp6,ltext110,text[55]);
-         } else {
-            bzero(href2, MAXLEN);
-            bzero(ltext110, 50);
-         }
-
-         sprintf(val2,"%s",href2);
-         sprintf(val3,"%3.2f%%",perc);
-         sprintf(val4,"%3.2f%%",inperc);
-         sprintf(val5,"%3.2f%%",ouperc);
-         sprintf(val6,"%s",buildtime(nnelap));
-         sprintf(val7,"%3.2f%%",perc2);
 
-         if((UserReportFields & USERREPORTFIELDS_CONNECT) == 0) {
-            bzero(wwork1, 255);
-            bzero(hbc1, 30);
-         }
-         if((UserReportFields & USERREPORTFIELDS_BYTES) == 0) {
-            bzero(wwork2, 255);
-            bzero(hbc2, 30);
-         }
-         if((UserReportFields & USERREPORTFIELDS_MILISEC) == 0) {
-            bzero(wwork3, 255);
-            bzero(hbc3, 30);
-         }
-         if((UserReportFields & USERREPORTFIELDS_SETYB) == 0) {
-            bzero(val3, 255);
-            bzero(hbc4, 30);
-         }
-         if((UserReportFields & USERREPORTFIELDS_IN_CACHE_OUT) == 0) {
-            bzero(val4, 255);
-            bzero(val5, 255);
-            bzero(hbc5, 30);
-            bzero(hbc6, 30);
-         }
-         if((UserReportFields & USERREPORTFIELDS_USED_TIME) == 0) {
-            bzero(val6, 255);
-            bzero(hbc7, 30);
-         }
-         if((UserReportFields & USERREPORTFIELDS_PTIME) == 0) {
-            bzero(val7, 255);
-            bzero(hbc8, 30);
-         }
-         if(strncmp(tmsg," ",1) == 0)
-            bzero(hbc9, 30);
+            if(!LongUrl) {
+               char *endofhost=strchr(url,'/');
+               if (endofhost) *endofhost='\0';
+               strcpy(urly,url);
+            } else {
+               strcpy(urly,url);
+               url_module(url, module);
+               str=strchr(url,'/');
+               if (str){
+                  *str='\0';
+                  strcat(url,"...");
+                  strcat(url,module);
+               }
+            }
 
+            if(Privacy)
+               fprintf(fp_ou,"<td class=\"data2\"><span style=\"color:%s;\">%s</span></td>",PrivacyStringColor,PrivacyString);
+            else {
+               if(BlockIt[0]!='\0') {
+                  fprintf(fp_ou,"<td class=\"data2\"><a href=\"%s%s?url=%s\"><img src=\"%s/sarg-squidguard-block.png\" border=\"0\"></a><a href=\"http://%s\">&nbsp;%s</a></td>",wwwDocumentRoot,BlockIt,urly,tmp6,urly,urly);
+               } else
+                  fprintf(fp_ou,"<td class=\"data2\"><a href=\"http://%s\" title=\"%s\">%s</a></td>",urly,urly,url);
+            }
 
-         if(UserReportLimit<=0 || count<=UserReportLimit) {
-            fprintf(fp_ou,"<tr><td class=\"data\">%s</td><td class=\"data2\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td>%s</tr>\n",val2,httplink,wwork1,wwork2,val3,val4,val5,val6,wwork3,val7,tmsg);
+            if((UserReportFields & USERREPORTFIELDS_CONNECT) != 0)
+               fprintf(fp_ou,"<td class=\"data\">%s</td>",fixnum(twork,1));
+            if((UserReportFields & USERREPORTFIELDS_BYTES) != 0)
+               fprintf(fp_ou,"<td class=\"data\">%s</td>",fixnum(nnbytes,1));
+            if((UserReportFields & USERREPORTFIELDS_SETYB) != 0)
+               fprintf(fp_ou,"<td class=\"data\">%3.2f%%</td>",perc);
+            if((UserReportFields & USERREPORTFIELDS_IN_CACHE_OUT) != 0)
+               fprintf(fp_ou,"<td class=\"data\">%3.2f%%</td><td class=\"data\">%3.2f%%s</td>",inperc,ouperc);
+            if((UserReportFields & USERREPORTFIELDS_USED_TIME) != 0)
+               fprintf(fp_ou,"<td class=\"data\">%s</td>",buildtime(nnelap));
+            if((UserReportFields & USERREPORTFIELDS_MILISEC) != 0)
+               fprintf(fp_ou,"<td class=\"data\">%s</td>",fixnum2(nnelap,1));
+            if((UserReportFields & USERREPORTFIELDS_PTIME) != 0)
+               fprintf(fp_ou,"<td class=\"data\">%3.2f%%</td>",perc2);
+
+            if(strncmp(tmsg,"OK",2) != 0)
+               fprintf(fp_ou,"<td class=\"data\">%s</td>",text[46]);
+
+            fputs("</tr>\n",fp_ou);
             count++;
          }
 
@@ -566,60 +525,23 @@ void htmlrel(void)
          inperc=inperc / tnbytes;
       } else inperc=0;
 
-      sprintf(wwork1,"%s",fixnum(tnacc,1));
-      sprintf(wwork2,"%s",fixnum(tnbytes,1));
-      sprintf(wwork3,"%s",fixnum2(tnelap,1));
-
-      sprintf(val2,"%s%s",href2,ltext110);
-      sprintf(val3,"%3.2f%%",perc);
-      sprintf(val4,"%3.2f%%",inperc);
-      sprintf(val5,"%3.2f%%",ouperc);
-      sprintf(val6,"%s",buildtime(tnelap));
-      sprintf(val7,"%3.2f%%",perc2);
-
-      strcpy(hbc1,"class=\"header2\"");
-      strcpy(hbc2,"class=\"header2\"");
-      strcpy(hbc3,"class=\"header2\"");
-      strcpy(hbc4,"class=\"header2\"");
-      strcpy(hbc5,"class=\"header2\"");
-      strcpy(hbc6,"class=\"header2\"");
-      strcpy(hbc7,"class=\"header2\"");
-      strcpy(hbc8,"class=\"header2\"");
-      strcpy(hbc9,"class=\"header\"");
-
-      if((UserReportFields & USERREPORTFIELDS_CONNECT) == 0) {
-         bzero(wwork1, 255);
-         bzero(hbc1, 30);
-      }
-      if((UserReportFields & USERREPORTFIELDS_BYTES) == 0) {
-         bzero(wwork2, 255);
-         bzero(hbc2, 30);
-      }
-      if((UserReportFields & USERREPORTFIELDS_MILISEC) == 0) {
-         bzero(wwork3, 255);
-         bzero(hbc3, 30);
-      }
-      if((UserReportFields & USERREPORTFIELDS_SETYB) == 0) {
-         bzero(val3, 255);
-         bzero(hbc4, 30);
-      }
-      if((UserReportFields & USERREPORTFIELDS_IN_CACHE_OUT) == 0) {
-         bzero(val4, 255);
-         bzero(hbc5, 30);
-         bzero(val5, 255);
-         bzero(hbc6, 30);
-      }
-      if((UserReportFields & USERREPORTFIELDS_USED_TIME) == 0) {
-         bzero(val6, 255);
-         bzero(hbc7, 30);
-      }
-      if((UserReportFields & USERREPORTFIELDS_PTIME) == 0) {
-         bzero(val7, 255);
-         bzero(hbc8, 30);
-      }
-
       if((UserReportFields & USERREPORTFIELDS_TOTAL) != 0) {
-         fprintf(fp_ou,"<tr><th></th><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th></tr>\n",hbc9,text[107],hbc1,wwork1,hbc2,wwork2,hbc4,val3,hbc5,val4,hbc6,val5,hbc7,val6,hbc3,wwork3,hbc8,val7);
+         fprintf(fp_ou,"<tr><th></th><th class=\"header\">%s</th>",text[107]);
+         if((UserReportFields & USERREPORTFIELDS_CONNECT) != 0)
+            fprintf(fp_ou,"<th class=\"header2\">%s</th>",fixnum(tnacc,1));
+         if((UserReportFields & USERREPORTFIELDS_BYTES) != 0)
+            fprintf(fp_ou,"<th class=\"header2\">%s</th>",fixnum(tnbytes,1));
+         if((UserReportFields & USERREPORTFIELDS_SETYB) != 0)
+            fprintf(fp_ou,"<th class=\"header2\">%3.2f%%</th>",perc);
+         if((UserReportFields & USERREPORTFIELDS_IN_CACHE_OUT) != 0)
+            fprintf(fp_ou,"<th class=\"header2\">%3.2f%%</th><th class=\"header2\">%3.2f%%</th>",inperc,ouperc);
+         if((UserReportFields & USERREPORTFIELDS_USED_TIME) != 0)
+            fprintf(fp_ou,"<th class=\"header2\">%s</th>",buildtime(tnelap));
+         if((UserReportFields & USERREPORTFIELDS_MILISEC) != 0)
+            fprintf(fp_ou,"<th class=\"header2\">%s</th>",fixnum2(tnelap,1));
+         if((UserReportFields & USERREPORTFIELDS_PTIME) != 0)
+            fprintf(fp_ou,"<th class=\"header2\">%3.2f%%</th>",perc2);
+         fputs("</tr>\n",fp_ou);
       }
 
       fclose(fp_in);
@@ -695,43 +617,20 @@ void htmlrel(void)
          twork2=ntotuser;
          twork=ttnacc/twork2;
 
-         strcpy(wwork1,fixnum(twork,1));
-         strcpy(wwork2,fixnum(totbytes2,1));
-         strcpy(wwork3,fixnum2(totelap2,1));
-
-         sprintf(val6,"%s",buildtime(totelap2));
-         sprintf(val7,"%3.2f%%",perc2);
-
-         strcpy(hbc1,"class=\"header2\"");
-         strcpy(hbc2,"class=\"header2\"");
-         strcpy(hbc3,"class=\"header2\"");
-         strcpy(hbc4,"class=\"header2\"");
-         strcpy(hbc5,"class=\"header2\"");
-         strcpy(hbc6,"class=\"header\"");
-
-         if((UserReportFields & USERREPORTFIELDS_CONNECT) == 0) {
-            bzero(wwork1, 255);
-            bzero(hbc1, 30);
-         }
-         if((UserReportFields & USERREPORTFIELDS_BYTES) == 0) {
-            bzero(wwork2, 255);
-            bzero(hbc2, 30);
-         }
-         if((UserReportFields & USERREPORTFIELDS_MILISEC) == 0) {
-            bzero(wwork3, 255);
-            bzero(hbc3, 30);
-         }
-         if((UserReportFields & USERREPORTFIELDS_USED_TIME) == 0) {
-            bzero(val6, 255);
-            bzero(hbc4, 30);
-         }
-         if((UserReportFields & USERREPORTFIELDS_PTIME) == 0) {
-            bzero(val7, 255);
-            bzero(hbc5, 30);
-         }
-
          if((UserReportFields & USERREPORTFIELDS_AVERAGE) != 0) {
-            fprintf(fp_ou,"<tr><th></th><th %s>%s</th><th %s>%s</th><th %s>%s</th><th></th><th></th><th></th><th %s>%s</th><th %s>%s</th><th %s>%s</th></tr>\n",hbc6,text[96],hbc1,wwork1,hbc2,wwork2,hbc4,val6,hbc3,wwork3,hbc5,val7);
+            fprintf(fp_ou,"<tr><th></th><th class=\"header\">%s</th>",text[96]);
+            if((UserReportFields & USERREPORTFIELDS_CONNECT) != 0)
+               fprintf(fp_ou,"<th class=\"header2\">%s</th>",fixnum(twork,1));
+            if((UserReportFields & USERREPORTFIELDS_BYTES) != 0)
+               fprintf(fp_ou,"<th class=\"header2\">%s</th>",fixnum(totbytes2,1));
+            fprintf(fp_ou,"<th></th><th></th><th></th>");
+            if((UserReportFields & USERREPORTFIELDS_USED_TIME) != 0)
+               fprintf(fp_ou,"<th class=\"header2\">%s</th>",buildtime(totelap2));
+            if((UserReportFields & USERREPORTFIELDS_MILISEC) != 0)
+               fprintf(fp_ou,"<th class=\"header2\">%s</th>",fixnum2(totelap2,1));
+            if((UserReportFields & USERREPORTFIELDS_PTIME) != 0)
+               fprintf(fp_ou,"<th class=\"header2\">%3.2f%%</th>",perc2);
+            fputs("</tr>\n",fp_ou);
          }
       } /* added */
       tnacc=0;
@@ -752,7 +651,6 @@ void htmlrel(void)
 
    }
 
-   (void)rewinddir(dirp);
    (void)closedir(dirp);
    greport_cleanup();
 
index 9fac0f8ba313ef323a2ef80163313140e02d6fd8..9e52f8a5c6586fd1512c4949be080956b7241544 100755 (executable)
@@ -349,7 +349,6 @@ char wwork1[MAXLEN];
 char wwork2[MAXLEN];
 char wwork3[MAXLEN];
 char mask[MAXLEN];
-char httplink[MAXLEN];
 char html_old[MAXLEN];
 char site[MAXLEN];
 char us[50];