]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Don't save the unnecessary columns in the intermediary file that is sorted to produce...
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Mon, 26 Jul 2010 14:38:42 +0000 (14:38 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Mon, 26 Jul 2010 14:38:42 +0000 (14:38 +0000)
html.c

diff --git a/html.c b/html.c
index 1d90b0d9f539d176d8173e9013f2597e4a989952..ac108f5c619bcdace1bb6ef4c845c2724662ae56 100644 (file)
--- a/html.c
+++ b/html.c
@@ -49,6 +49,7 @@ void htmlrel(void)
    char warea[MAXLEN];
    char totuser[8];
    char tmp6[MAXLEN];
+   char *user_url;
    long long int tnacc=0, ttnacc=0, unacc=0;
    double perc=0, perc2=0, ouperc=0, inperc=0;
    int count;
@@ -368,16 +369,40 @@ void htmlrel(void)
                exit(EXIT_FAILURE);
             }
             while((buf=longline_read(fp_ip,line1))!=NULL) {
-               if(strstr(buf,url) != 0) {
-                  fprintf(fp_ip2,"%s\n",buf);
+               getword_start(&gwarea,buf);
+               if (getword(user_ip,sizeof(user_ip),&gwarea,'\t')<0) {
+                  debuga(_("Maybe you have a broken user IP in your %s file\n"),tmp3);
+                  exit(EXIT_FAILURE);
+               }
+               if (getword_ptr(buf,&user_url,&gwarea,'\t')<0) {
+                  debuga(_("Maybe you have a broken url in your %s file\n"),tmp3);
+                  exit(EXIT_FAILURE);
+               }
+               if (strncmp(user_url,url,strlen(url))!=0) continue;
+               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_skip(15,&gwarea,'\t')<0) {
+                  debuga(_("Maybe you have a broken time in your %s file\n"),tmp3);
+                  exit(EXIT_FAILURE);
+               }
+               if (getword_atoll(&userbytes,&gwarea,'\t')<0) {
+                  debuga(_("Maybe you have a broken size in your %s file\n"),tmp3);
+                  exit(EXIT_FAILURE);
                }
+               if (getword_atoll(&userelap,&gwarea,'\0')<0) {
+                  debuga(_("Maybe you have a broken elapsed time in your %s file\n"),tmp3);
+                  exit(EXIT_FAILURE);
+               }
+               fprintf(fp_ip2,"%s\t%"PRIu64"\t%"PRIu64"\n",user_ip,(uint64_t)userbytes,(uint64_t)userelap);
             }
             longline_destroy(&line1);
 
             fclose(fp_ip);
             fclose(fp_ip2);
 
-            sprintf(csort,"sort -n -T \"%s\" -k 1,1 -k 5,5 -o \"%s\" \"%s\"",tmp,tmp3,tmp2);
+            sprintf(csort,"sort -n -T \"%s\" -k 1,1 -k 2,2 -o \"%s\" \"%s\"",tmp,tmp3,tmp2);
             cstatus=system(csort);
             if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
                debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
@@ -402,18 +427,6 @@ void htmlrel(void)
                   debuga(_("Maybe you have a broken user IP in your %s file\n"),tmp3);
                   exit(EXIT_FAILURE);
                }
-               if (getword_ptr(NULL,NULL,&gwarea,'\t')<0) {
-                  debuga(_("Maybe you have a broken url in your %s file\n"),tmp3);
-                  exit(EXIT_FAILURE);
-               }
-               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_skip(15,&gwarea,'\t')<0) {
-                  debuga(_("Maybe you have a broken time in your %s file\n"),tmp3);
-                  exit(EXIT_FAILURE);
-               }
                if (getword_atoll(&userbytes,&gwarea,'\t')<0) {
                   debuga(_("Maybe you have a broken size in your %s file\n"),tmp3);
                   exit(EXIT_FAILURE);