]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Trivial changes made while ensuring the reports are complete and accurate
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Mon, 15 Feb 2010 10:09:04 +0000 (10:09 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Mon, 15 Feb 2010 10:09:04 +0000 (10:09 +0000)
log.c
report.c

diff --git a/log.c b/log.c
index 3cbf8f998981e6f49e039863a5235a9fd8dd86f2..bb399007f8b0b895a091f6a47697c420e276fc5e 100644 (file)
--- a/log.c
+++ b/log.c
@@ -1419,7 +1419,6 @@ int main(int argc,char *argv[])
                if(fp_log && ilf!=ILF_Sarg)
                   fprintf(fp_log, "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n",dia,hora,user,ip,url,tam,code,elap,smartfilter);
 
-
                totregsg++;
 
                if(download_flag && strstr(code,"DENIED") == 0) {
index 16ca34ea85114aff22b00086733f08ac3c322c44..35e9f00b842939143689f986c3763cd62a37378c 100644 (file)
--- a/report.c
+++ b/report.c
@@ -71,6 +71,7 @@ void gerarel(void)
    int url_len;
    int ourl_size=0;
    int ourltt_size=0;
+   int same_url;
    struct getwordstruct gwarea;
    struct longlinestruct line;
 
@@ -90,7 +91,7 @@ void gerarel(void)
    if(UserAgentLog[0] != '\0' && email[0] == '\0') useragent();
 
    sprintf(wdirname,"%s/sarg-general",dirname);
-   if((fp_gen=MY_FOPEN(wdirname,"a"))==NULL){
+   if((fp_gen=MY_FOPEN(wdirname,"w"))==NULL){
       fprintf(stderr, "SARG: (report) %s: %s\n",text[45],wdirname);
       exit(1);
    }
@@ -208,6 +209,7 @@ void gerarel(void)
             strcpy(oldacchora,acchora);
             rtotal++;
          }
+         same_url=(strcmp(oldurl,accurl) == 0);
 
          if(site[0] != '\0') {
             if(strcmp(oldaccuser,accuser) != 0){
@@ -223,7 +225,7 @@ void gerarel(void)
                oucache=0;
             }
          } else {
-            if(strcmp(oldurl,accurl) != 0 || strcmp(oldaccuser,accuser) != 0){
+            if(!same_url || strcmp(oldaccuser,accuser) != 0){
                if(strstr(oldacccode,"DENIED") != 0)
                   strcpy(oldmsg,text[46]);
                else
@@ -314,25 +316,27 @@ void gerarel(void)
 
          strcpy(oldacccode,acccode);
          strcpy(oldaccip,accip);
-         url_len=strlen(accurl);
-         if (url_len>=ourl_size) {
-            ourl_size=url_len+1;
-            oldurl=realloc(oldurl,ourl_size);
-            if (!oldurl) {
-               debuga(_("Not enough memory to store the url"));
-               exit(1);
+         if (!same_url) {
+            url_len=strlen(accurl);
+            if (url_len>=ourl_size) {
+               ourl_size=url_len+1;
+               oldurl=realloc(oldurl,ourl_size);
+               if (!oldurl) {
+                  debuga(_("Not enough memory to store the url"));
+                  exit(1);
+               }
             }
+            strcpy(oldurl,accurl);
          }
-         strcpy(oldurl,accurl);
          strcpy(oldaccdia,accdia);
          strcpy(oldacchora,acchora);
 
       }
-      bzero(user,sizeof(user));
       fclose(fp_in);
-      unlink(tmp3);
       longline_free(&line);
       if (oldurltt) free(oldurltt);
+      unlink(tmp3);
+      bzero(user,sizeof(user));
    }
    closedir(dirp);
 
@@ -596,7 +600,6 @@ static void gravager(FILE *fp_gen, const char *user, long long int nacc, const c
 {
    fprintf(fp_gen,"%s\t%lld\t%lld\t%s\t%s\t%s\t%s\t%lld\t%lld\t%lld\n",user,nacc,nbytes,url,ip,hora,dia,nelap,incache,oucache);
    return;
-
 }
 
 static void grava_SmartFilter(const char *dirname, const char *user, const char *ip, const char *data, const char *hora, const char *url, const char *smart)