]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Fix the reporting of the IP addresses from which the user connected to the internet...
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Mon, 26 Jul 2010 14:38:27 +0000 (14:38 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Mon, 26 Jul 2010 14:38:27 +0000 (14:38 +0000)
CMakeLists.txt
html.c
include/info.h

index 7e539a7ac7b8eb4085d818ae01f1dddd0179e642..0f0c2a925e7a6cabac9dba5bbb11621611171be7 100755 (executable)
@@ -3,7 +3,7 @@ PROJECT(sarg C)
 SET(sarg_VERSION 2)
 SET(sarg_REVISION "3.1-pre1")
 SET(sarg_BUILD "")
-SET(sarg_BUILDDATE "Jul-19-2010")
+SET(sarg_BUILDDATE "Jul-26-2010")
 
 INCLUDE(AddFileDependencies)
 INCLUDE(CheckIncludeFile)
diff --git a/html.c b/html.c
index 8d617d3254d58f3d4dd68f128f49a2fff0abf03c..1d90b0d9f539d176d8173e9013f2597e4a989952 100644 (file)
--- a/html.c
+++ b/html.c
@@ -43,7 +43,6 @@ void htmlrel(void)
    char arqin[MAXLEN], arqou[MAXLEN], arqper[MAXLEN], arqip[MAXLEN];
    char *url, tmsg[50], csort[MAXLEN];
    char user[MAXLEN], duser[MAXLEN];
-   char userhora[9], userdia[9];
    char user_ip[MAXLEN], olduserip[MAXLEN], tmp2[MAXLEN], tmp3[MAXLEN];
    char denied_report[255];
    char *str;
@@ -369,8 +368,9 @@ void htmlrel(void)
                exit(EXIT_FAILURE);
             }
             while((buf=longline_read(fp_ip,line1))!=NULL) {
-               if(strstr(buf,url) != 0)
-                  fputs(buf,fp_ip2);
+               if(strstr(buf,url) != 0) {
+                  fprintf(fp_ip2,"%s\n",buf);
+               }
             }
             longline_destroy(&line1);
 
@@ -406,11 +406,11 @@ void htmlrel(void)
                   debuga(_("Maybe you have a broken url in your %s file\n"),tmp3);
                   exit(EXIT_FAILURE);
                }
-               if (getword(userdia,sizeof(userdia),&gwarea,'\t')<0) {
+               if (getword_skip(15,&gwarea,'\t')<0) {
                   debuga(_("Maybe you have a broken day in your %s file\n"),tmp3);
                   exit(EXIT_FAILURE);
                }
-               if (getword(userhora,sizeof(userhora),&gwarea,'\t')<0) {
+               if (getword_skip(15,&gwarea,'\t')<0) {
                   debuga(_("Maybe you have a broken time in your %s file\n"),tmp3);
                   exit(EXIT_FAILURE);
                }
@@ -418,17 +418,27 @@ void htmlrel(void)
                   debuga(_("Maybe you have a broken size in your %s file\n"),tmp3);
                   exit(EXIT_FAILURE);
                }
-               if (getword_atoll(&userelap,&gwarea,'\t')<0) {
+               if (getword_atoll(&userelap,&gwarea,'\0')<0) {
                   debuga(_("Maybe you have a broken elapsed time in your %s file\n"),tmp3);
                   exit(EXIT_FAILURE);
                }
                if(strcmp(user_ip,olduserip) != 0) {
-                  sprintf(wwork1,"%s",fixnum(unbytes,1));
-                  /*
-                  This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
-                  to print a long long int unless it is exactly 64-bits long.
-                  */
-                  fprintf(fp_ou,"<tr><td></td><td class=\"data\">%s</td><td></td><td class=\"data\">%s</td><td></td><td></td><td></td><td class=\"data\">%s</td><td class=\"data\">%"PRIu64"</td></tr>\n",olduserip,wwork1,buildtime(unelap),(uint64_t)unelap);
+                  if (olduserip[0]!='\0') {
+                     fprintf(fp_ou,"<tr><td></td><td class=\"data\">%s</td>",olduserip);
+                     if((UserReportFields & USERREPORTFIELDS_CONNECT) != 0)
+                        fputs("<td></td>",fp_ou);
+                     if((UserReportFields & USERREPORTFIELDS_BYTES) != 0)
+                        fprintf(fp_ou,"<td class=\"data\">%s</td>",fixnum(unbytes,1));
+                     if((UserReportFields & USERREPORTFIELDS_SETYB) != 0)
+                        fputs("<td></td>",fp_ou);
+                     if((UserReportFields & USERREPORTFIELDS_IN_CACHE_OUT) != 0)
+                        fputs("</td><td></td><td></td>",fp_ou);
+                     if((UserReportFields & USERREPORTFIELDS_USED_TIME) != 0)
+                        fprintf(fp_ou,"<td class=\"data\">%s</td>",buildtime(unelap));
+                     if((UserReportFields & USERREPORTFIELDS_MILISEC) != 0)
+                        fprintf(fp_ou,"<td class=\"data\">%s</td>",fixnum2(unelap,1));
+                     fputs("</tr>\n",fp_ou);
+                  }
 
                   strcpy(olduserip,user_ip);
                   unacc=0;
@@ -436,8 +446,8 @@ void htmlrel(void)
                   unelap=0;
                }
 
-               unbytes=unbytes+userbytes;
-               unelap=unelap+userelap;
+               unbytes+=userbytes;
+               unelap+=userelap;
             }
 
             fclose(fp_ip);
@@ -446,12 +456,22 @@ void htmlrel(void)
             unlink(tmp2);
             unlink(tmp3);
 
-            sprintf(wwork1,"%s",fixnum(unbytes,1));
-            /*
-            This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
-            to print a long long int unless it is exactly 64-bits long.
-            */
-            fprintf(fp_ou,"<tr><td></td><td class=\"data\">%s</td><td></td><td class=\"data\">%s</td><td></td><td></td><td></td><td class=\"data\">%s</td><td class=\"data\">%"PRIu64"</td></tr>\n",olduserip,wwork1,buildtime(unelap),(uint64_t)unelap);
+            if (olduserip[0]!='\0') {
+               fprintf(fp_ou,"<tr><td></td><td class=\"data\">%s</td>",olduserip);
+               if((UserReportFields & USERREPORTFIELDS_CONNECT) != 0)
+                  fputs("<td></td>",fp_ou);
+               if((UserReportFields & USERREPORTFIELDS_BYTES) != 0)
+                  fprintf(fp_ou,"<td class=\"data\">%s</td>",fixnum(unbytes,1));
+               if((UserReportFields & USERREPORTFIELDS_SETYB) != 0)
+                  fputs("<td></td>",fp_ou);
+               if((UserReportFields & USERREPORTFIELDS_IN_CACHE_OUT) != 0)
+                  fputs("</td><td></td><td></td>",fp_ou);
+               if((UserReportFields & USERREPORTFIELDS_USED_TIME) != 0)
+                  fprintf(fp_ou,"<td class=\"data\">%s</td>",buildtime(unelap));
+               if((UserReportFields & USERREPORTFIELDS_MILISEC) != 0)
+                  fprintf(fp_ou,"<td class=\"data\">%s</td>",fixnum2(unelap,1));
+               fputs("</tr>\n",fp_ou);
+            }
          }
 
          unacc=0;
index 2a261626d951973375ed98cbb5798f69cff0b8d2..b08f87319f628f01863457bafb242ff0e5aa1ab0 100755 (executable)
@@ -1,3 +1,3 @@
-#define VERSION PACKAGE_VERSION" Jul-19-2010"
+#define VERSION PACKAGE_VERSION" Jul-26-2010"
 #define PGM PACKAGE_NAME
 #define URL "http://sarg.sourceforge.net"